Products List Shortcode
// Add Shortcode
function ppr_products_list( $atts , $content = null ) {
// WP_Query arguments
$args = array (
'post_type' => array( 'page' ),
'post_status' => array( 'publish' ),
'nopaging' => false,
'order' => 'ASC',
'orderby' => 'title',
);
// The Query
ppr_products = new WP_Query( $args );
// The Loop
if ( ppr_products->have_posts() ) {
while ( ppr_products->have_posts() ) {
ppr_products->the_post();
// do something
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
}
add_shortcode( 'pprproducts', 'ppr_products_list' );