Advertisement
Guest User

Untitled

a guest
Nov 5th, 2012
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * Answer to : http://www.reddit.com/r/Wordpress/comments/12k75o/how_would_i_list_10_blog_entries_total_5_of_which/
  5. */
  6.  
  7. $query = new WP_Query( array(
  8.     'posts_per_page' => 10
  9. ) );
  10.  
  11. if( $query->have_posts() ) {
  12.  
  13.     $idx = 0;
  14.     while( $query->have_posts() ) {
  15.         $query->the_post();
  16.  
  17.         if( $idx < 5 ) {
  18.             // Do stuff to display first 5
  19.             printf( '<h2>%s</h2>', get_the_title() );
  20.             the_content();
  21.         } else {
  22.  
  23.             // Do stuff to display the last 5 (title only)
  24.             printf( '<h2>%s</h2>', get_the_title() );
  25.         }
  26.         idx++;
  27.     }
  28. }
  29. wp_reset_postdata();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement