Side Bar List Recent Post and add custom CSS for Current Page
-
I have no problem listing the 5 most recent post titles in the side bar.
My problem is being able to assign a class to the ‘li’, but only to the Active ‘li’
My goal is when the user clicks the Post, it marks it as the current post (highlights the background of that title). If the user clicks another post, it highlights that one, indicating the user is currently on that post.My code to pull the 5 recent post.
[moderator: please mark any code using the ‘code’ button – see forum guidelines for posting code – the code below is already corrupted]
<ul> <?php $archive_query = new WP_Query('showposts=5'); while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <li class="Active"><a href="..." rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul>
My CSS
.share ul li a:hover,.share ul li.active a , .share ul li.current-active a, .share ul li.current-active a { color:#fff; background:#4e88c2 url(images/side-nav-a-bg.jpg) center left no-repeat; text-decoration:none; }
What happends, is that all the 5 post listed in the side bar display the background as Active.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Side Bar List Recent Post and add custom CSS for Current Page’ is closed to new replies.