Support » Fixing WordPress » Style oldest post

  • I’ve managed to find a loop that targets both the *latest* post, as well as the *rest* of the content. However, I need to find a loop that can style the *last* post.

    Would anyone know how this is done?

Viewing 1 replies (of 1 total)
  • vtxyzzy


    You can do this by saving the ID of the last post on the current page and the max number of pages and then compare those to the current values for each post. Here is some sample code:

    if (have_posts()) :
       $last_post = end($wp_query->posts);
       $last_id = $last_post->ID;
       $last_page = $wp_query->max_num_pages;
       while (have_posts()) :
          if ($last_page == $paged && $post->ID == $last_id) :
             // Put special code for last page here
          // Rest of loop code here
Viewing 1 replies (of 1 total)
  • The topic ‘Style oldest post’ is closed to new replies.