0

is there a quick and easy way to load all the posts, starting with the second post and making the first post the last post? If I use offset, I then lose the first post, but I don't want to lose it, I just want to change the sort order, ie. first becomes last and second becomes first post.

Thanks for your help.

  • 1
    Is this to work with pagination or not? And if so, does the first becomes last on each page, or does the first post of the first page become the very last post of the last page? – Stephen Harris Aug 24 '12 at 10:53
1

With pagination is easy :) -just retrieve all the posts, then skip the first one out. At the end rewind back to the beginning of the loop and output the post you missed out.

if( have_posts() ):

    while( have_posts() ): the_post();
         if( 0 == $wp_query->$current_post )
              continue;

         // Display all but the first post

    endwhile;

    //Rewind to the beginning
    rewind_posts();
    the_post();

    //Display first post

endif;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.