Support

Account

Home Forums General Issues Add "current" class to list of related posts Reply To: Add "current" class to list of related posts

  • I had to do a bit more searching but your suggestion sent me in the right direction, so thanks @elliot

    Here was my final code:

    <?php
    	global $post;
    	$the_post_ID = $post->ID;
    ?>
    	
    <?php foreach ( $posts as $post ) : ?>					
    	<li<?php if ( $post->ID == $the_post_ID ) echo ' class="current"'; ?>>
    	    <h3><a href="<?php the_permalink(); ?>" title="<?php echo get_the_title( $post->ID ); ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    	</li>
    <?php endforeach; ?>