/ Published in: PHP
URL: http://www.blogohblog.com/10-more-wordpress-hacks-for-easy-life/
Expand |
Embed | Plain Text
If you need to break display your posts in different sections (like in Magazine themes), where you want to display a fixed number of posts first, and the remaining later, you can use this code to make multiple loops (with offsetting the fixed posts in the later loop). The first loop that will pull and display 5 recent posts :- view source print? 1 <?php 2 query_posts('showposts=5'); 4 while (have_posts()) : the_post(); 5 $ids[] = get_the_ID(); 6 the_title(); 7 the_content(); 8 endwhile; 9 ?> And, the second loop that will exclude the above posts and show the remaining ones :- view source print? 1 <?php 3 while (have_posts()) : the_post(); 4 the_title(); 5 the_content(); 6 endwhile; 7 ?> This code basically pulls the post IDs that are not contained in the array $ids[].
You need to login to post a comment.
