Viewing 2 replies - 1 through 2 (of 2 total)
  • I am wondering this too, I think it cannot be done right now. Still digging in the source code.

    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');

    With:

    $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)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP Category Post List Widget] Highlight Active Post’ is closed to new replies.