Posted By

Ben on 03/02/10


Tagged

php wordpress loop


Versions (?)

A loop outside the normal loop


 / Published in: PHP
 

  1. <!-- loop name -->
  2. <?php $myloop = new WP_Query('category_name=CATEGORY&showposts=3');
  3. while ($myloop->have_posts()) : $myloop->the_post(); ?>
  4.  
  5. <!-- To store the IDs in a array -->
  6.  
  7.  
  8. <?php $myloop = new WP_Query('category_name=CATEGORY&showposts=3'); -->
  9. while ($myloop->have_posts()) : $myloop->the_post();
  10. &myloopids[] = $post->ID ?>
  11.  
  12. <!-- Posts in my loop but skipping the posts (IDs) in the array loop above
  13. <?php while (have_posts()) : the_post(); ?>
  14. <?php if (in_array($post->ID, $myloopIDs)) continue; update_post_caches($posts); ?>

Report this snippet  

You need to login to post a comment.