Created
February 11, 2018 08:06
-
-
Save akella/4c380b6eba2d08e81b455674032cd671 to your computer and use it in GitHub Desktop.
wp 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
<?php | |
$args = array( | |
'category_name' => 'news', | |
'posts_per_page' => 3 | |
); | |
$my_query = new WP_Query( $args ); | |
if ( $my_query->have_posts() ) { | |
while ( $my_query->have_posts() ) { | |
$my_query->the_post(); | |
// Post data goes here. | |
} | |
} | |
// Reset the `$post` data to the current post in main query. | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment