-
-
Save beardlessman/2f9cf530b0972dadb60ab248aa1060f9 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