Created
September 11, 2013 17:14
-
-
Save bMinaise/6526767 to your computer and use it in GitHub Desktop.
Wordpress Category Query
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
// WP_Query arguments | |
$args = array ( | |
'category_name' => 'gallery', | |
); | |
// The Query | |
$query = new WP_Query( $args ); | |
// The Loop | |
if ( $query->have_posts() ) { | |
while ( $query->have_posts() ) { | |
$query->the_post(); | |
// do something | |
} | |
} else { | |
// no posts found | |
} | |
// Restore original Post Data | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment