• 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)
  • 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()) :
          the_post();
          if ($last_page == $paged && $post->ID == $last_id) :
             // Put special code for last page here
          endif;
          // Rest of loop code here
       endwhile;
    endif;
Viewing 1 replies (of 1 total)
  • The topic ‘Style oldest post’ is closed to new replies.