WP Category Post List Widget
Highlight Active Post (3 posts)

  1. JWSchaeffer
    Posted 4 years ago #

    I want the active post to be highlighted within the WP Category Post List.

    How do I make this happen?


  2. flavigne
    Posted 3 years ago #

    I am wondering this too, I think it cannot be done right now. Still digging in the source code.

  3. pdboller
    Posted 3 years ago #

    I know this is an old post, but I was looking for this today and could not find a solution so I thought I'd post what I did. Please note: I am NOT a coder - it took me a while to tweak the code to get to this point, and it may be wrong, but it works for me so it may work for others too.

    Also, this probably removes some/all of the functionality of the widget options. I was working on a custom theme that the end user will not change, so this does not affect me.

    Use at your own risk!

    Here's what I did.

    In /plugins/wp-category-posts-list/includes/wp_cpl_output_gen.php look for /** Initiate the post list widget HTML. Replace:

    $default_class = ((true == $op['alternate_list_css'])? (($i%2 == 0)? 'wp-cpl wp-cpl-even' : 'wp-cpl wp-cpl-odd') : 'wp-cpl');


    $current_url_1 = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    if($current_url_1 == get_permalink($post->ID)) {
    $default_class = 'wp-cpl wp-cpl-current';
    } else {
    $default_class = ((true == $op['alternate_list_css'])? (($i%2 == 0)? 'wp-cpl wp-cpl-even' : 'wp-cpl wp-cpl-odd') : 'wp-cpl');

    (I basically replace the automatically generated default class with a new current/active class IF the specific link is the current one/same as the current URL).

    After this, just add the class to your CSS file to give the current link a different style.

    If anyone has a better option/solution, I'm always happy to learn something new!
    (Edit: tried to fix some formatting issues for this post)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Category Post List Widget
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic