-
-
Save zagriyen/08c7381b89101f3a77b4f96cf680fe25 to your computer and use it in GitHub Desktop.
WP_query fields
This file contains hidden or 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 | |
// Create a new Query | |
$args = array( | |
'post_type' => 'post', | |
'cat' => '1,6,8', | |
'author_name' => 'john', | |
'posts_per_page' => 5, | |
'fields' => 'ids' | |
); | |
$the_query = new WP_Query( $args ); | |
// The Loop | |
echo '<ul>': | |
while ( $the_query->have_posts() ): | |
$the_query->the_post(); | |
echo '<li>' . get_the_ID() . '</li>'; | |
endwhile; | |
echo '</ul>': | |
// Restore original Query | |
wp_reset_query(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment