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; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.