Query Posts
Tip: How to add active class with jQuery (1 post)

  1. anemo
    Posted 4 years ago #


    I was lacking an active class for the selected post in the widgets list so I made this little script to add it retrospectively.

    Append this jQuery-script to the end of your single.php:

    <!-- Add active class to Query Posts list -->
    <script type="text/javascript">
    jQuery(document).ready(function() {
    	jQuery('.posts .post-<?php the_ID(); ?>').addClass('active');

    Then add this to your CSS (example):

    .widget-container.posts div.active a {
    font-weight: bold;

    Check this out if you don't know how to include jQuery the right way in WP.


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 4 years ago by anemo
  • This topic is not a support question
  • WordPress version: 3.0.5