• Resolved hulku

    (@hulku)


    I want to output the title, preview image and an except from the latest X number of posts onto the front page of a site i’m building which is fairly common, is it possible to configure the loop so that the most recent post gets a certain styling, then the 2nd most recent gets a certain styling, then the third and onwards gets another styling.

    I want to do this programmatically in the loop so no extra information needs to be added to the post for example no extra categories, or custom fields

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • if you theme uses <?php post_class(); ?> in the post div, then change that to, for example:

    <?php $extra = ($wp_query->current_post == 0) ? 'first-post' : (($wp_query->current_post == 1)? 'second-post' : 'other-post'); post_class($extra); ?>

    this will add the css classes .first-post, .second-post, and .other-post to the post div.

    adapted from https://www.transformationpowertools.com/wordpress/styling-first-post-different

    might be different in your theme, but you haven’t posted any information.

    Thread Starter hulku

    (@hulku)

    Thanks alchymyth, that looks interesting i’ll play with it. I couldn’t post much information about the theme i’m using it for because at the moment its still in my head.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Styling the loop chronologically’ is closed to new replies.