WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. anemo
    Member
    Posted 3 years ago #

    Hi!

    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.noConflict();
    jQuery(document).ready(function() {
    	jQuery('.posts .post-<?php the_ID(); ?>').addClass('active');
    });
    </script>

    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.

    http://wordpress.org/extend/plugins/query-posts/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

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