Last active
November 18, 2015 19:49
-
-
Save bmodena/77d80d62d7576a167300 to your computer and use it in GitHub Desktop.
Wordpress WP_Query Sample of custom post type products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get all products | |
$args = array( | |
'posts_per_page' => -1, | |
'post_type' => 'products', | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'no_found_rows' => true | |
); | |
//Set up Objects | |
$products = new WP_Query($args); | |
//The loop | |
if ( $products->have_posts() ) : while ( $products->have_posts() ) : $products->the_post(); | |
// Product loop | |
get_template_part( 'partials/loops/products' ); | |
endwhile; endif; | |
//Reset Post data | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment