corsonr
1/5/2013 - 2:46 PM

WP_query fields

WP_query fields

<?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();
 
?>