Turnout Mag Theme - Modifying index.php (2 posts)

  1. rvk2
    Posted 6 years ago #

    Hey everyone. I'm using the Turnout mag theme for a site. It's a great theme that lays out all the posts in a grid layout. Here is the site:

    What I wanted to do was modify it so that the latest entry is highlighted and perhaps change the color of the "box". Unfortunately, the php code in index.php goes through a for loop to list all the posts in boxes. I am not sure if there is a way for me to display the first post differently. I ran into a road block with this and can't think of any solutions. Would appreciate any help from the wise members on this forum.

  2. esmi
    Forum Moderator
    Posted 6 years ago #

    Assuming that the start of your current Loop looks something like:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">

    you could try changing it to:

    <?php $c = 0;$style = ''; ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php $c++;
    if( $c == 1 ) $style=' highlight'; ?>
    <div class="post<?php echo $style;?>">

    That should add the class "first" to the most recent post only. You could then use this class in your theme's stylesheet to highlight the most recent post - e.g.:

    `#content .post .first {border-color:#FF9000;}

Topic Closed

This topic has been closed to new replies.

About this Topic