• Hi all,

    Okay so I’m a bit of a wordpress newbie and I know this is a common concern and I did my research about similar topics in this forum with nothing working.

    I need help on editing my category.php to get the most recent post in the current category and style it differently with the post title, the summary and the featured image. Again, this should apply to all category pages.

    I have here two pictures – the existing layout and how I want it to look like.

    Existing layout

    Target layout

    I tried existing solutions for separate pages(homepage) for this but when it comes to the respective category page, it just won’t work. Maybe because repeating posts isn’t allowed?

Viewing 1 replies (of 1 total)
  • general approach – the details might vary with your theme – is to use the default loop counter variable to check for the top post and use a condtional statement in category.pgp to show a different output;

    example:

    if (have_posts()) : while (have_posts()) :  the_post();
    
      if( $wp_query->current_post == 0 && !is_paged() ) : ?>
        the way to show the last post
      <?php else : ?>
        the existing way to show all other posts
      </php endif;
    
    endwhile;
    endif;
Viewing 1 replies (of 1 total)
  • The topic ‘Style most recent post from same category differently’ is closed to new replies.