In my menu I have a page that is called Campaign
.
When the user enters to Campaign
the page displays the last custom post type of campaign-post
.
In the sidebar of Campaign
page, I'm displaying a list of all campaign-post
custom posts.
The problem is that I don't know how to highlight (add current
class) to the last post title in the list that is displayed when the user enters to Campaign
page.
This is how I'm displaying the list:
<ul class="post-list">
<?php $query = new WP_Query( array( 'post_type' => 'campaign-post' ) );
while ( $query->have_posts() ) : $query->the_post();
echo '<li><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></li>';
endwhile; ?>
</ul>
Any ideas?