WordPress.org

Support

Support » Themes and Templates » [Resolved] Blog post styling

[Resolved] Blog post styling

  • I am creating a custom theme for my site and am looking to create a template for my index.php file where my newest blog post is styled differently from others to highlight it from others, and the following three posts are styled differently still, with older posts in a third style. The first four posts will be similar in style to this: http://insideonline.co.uk/magazine/. I would also be looking to utilize the Infinite Scroll feature in Jetpack and would be looking for all appended posts to have the same style as the older posts.

    My question would be how do I tell my theme to differentiate between the order of posts, setting the first post and the following three posts apart from others? Is there a set function to differentiate the posts?

Viewing 2 replies - 1 through 2 (of 2 total)
  • you could try to work with the loop counter 'current_post';

    example for a default loop:

    <?php if( $wp_query->current_post == 0 && !is_paged() ) { ?>
    FIRST POST on FIRST PAGE
    <?php } elseif( $wp_query->current_post <= 3 && !is_paged() ) { ?>
    POSTs TWO to FOUR on FIRST PAGE
    <?php } else { ?>
    OTHER POSTs
    <?php } ?>

    I’ve just put that code inside my loop and, from what I can see, that has had the exact effect I wanted, even if I use multiple pages. That is perfect, thank you so much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Blog post styling’ is closed to new replies.
Skip to toolbar