Sample WP_Query


/ Published in: PHP
Save to your folder(s)

For more parameters: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. // Start WP_Query for only the ID's from above
  4. $first_query = new WP_Query(
  5. 'post_type' => 'page',
  6. 'post__in' => array(6,7,8),
  7. 'category_name' => 'stuff',
  8. )
  9. );
  10.  
  11. ?>
  12.  
  13. <?php while($first_query->have_posts()) : $first_query->the_post(); ?>
  14. <?php the_title(); ?>
  15. <?php endwhile; ?>
  16. <?php wp_reset_postdata(); ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.