When you have a menu for say pages, it's easy to highlight your current page, since WP puts a class on it.
But what I have is a sidebar with the 20 latest posts in a loop and a separate main content area for the normal page loop and single page/category page etc.
My sidebar loop looks like this.
<ul>
<?php
$sidebar_query = new WP_Query(array(
'showposts' => 20
) );
?>
<?php while ($sidebar_query->have_posts()) : $sidebar_query->the_post(); ?>
<li>
<?php if(has_post_thumbnail()) :?>
<div class="figure">
<?php the_post_thumbnail('sidethumb'); ?>
</div> <!-- end div figure //centers thumbnail -->
<?php else :?>
<?php endif;?>
<a href="<?php the_permalink() ?>">
<span class="theparentcat">
<?php
$cat_names = wp_list_pluck( get_the_category(), 'cat_name');
echo wp_sprintf_l( '%l', $cat_names );
?>
</span>
<h2><?php the_title (); ?></h2>
<span class="thetime">
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
</span>
</a>
</li>
<?php endwhile; wp_reset_query(); ?>
</ul>
Now, what'd be the best way (if there's a way) to highlight the current post when on a single page? Now I could echo out a class or something in there, but then it'd be applied to all the posts in the loop so that'd be useless.
So I've got say,
Story one Story two Story three
in the sidebar and I'm on the page of story 1, how would one add a class to only that post so it can be highlighted with css?