Take the 2-minute tour ×

Unlike the (WP standard) Custom Menu widget, the Recent Posts widget does not add the current_menu_item class when a post is selected (being displayed).

This seems like a major oversight, am I missing something? If not, does anyone know of a third party widget that lists the most recent posts and includes the current_menu_item class (or equivalent)? ...or perhaps some magical hack to achieve the result of adding a class to the active menu item?

share|improve this question

1 Answer 1

The core Recent Posts Widget does not output any classes for the current post - probably because the Widget semantically is a list of posts, rather than a navigation menu, and therefore has no intended purpose to reflect current location.

That said, with a bit of CSS/jQuery trickery, you could target the current post by matching the current post's permalink and/or ID to the href and/or title attribute of the Recent Posts Widget list item link.

While the implementation itself is probably outside the scope of WPSE, the relevant code is here:

<?php endwhile; ?>

Use jQuery to match e.g. .widget li a[href=<?php get_permalink(); ?>], or something along those lines.

share|improve this answer

Your Answer


