Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #247529

    Hi support team!!!

    I need the current blog category highlighted on the sidebar in my blog entries. How can I do that?

    Thanks for the help.

    Cheers

    • This topic was modified 10 years, 7 months ago by claraelisa.
    #248515

    Hi claraelisa!

    On your custom css add the following

    
    #top .widget ul li.current-cat { background-color: #f5f5f5 // the #f5f5f5 it's just an example, you can add color or change the background. }
    

    Regards,
    David

    • This reply was modified 10 years, 7 months ago by David.
    #248543
    This reply has been marked as private.
    #249493

    Hey!

    Please adjust David’s code a bit and use it as following

    #top .widget ul li.current-cat { background-color: #f5f5f5; }

    Cheers!
    Yigit

    #249886

    Hi!
    Still not working :(

    What could it be?

    #250024

    Hey!

    Please flush browser cache and refresh your page a few times. It does work fine on my end – http://i.imgur.com/Usrsol8.png

    Best regards,
    Yigit

    #250260

    Thanks Yigit.

    well it works when i click on the category, but i want it to be highlighted when i’m inside of any article that belongs to that category. Is that possible?

    Thanks for all the help

    #250954

    Hey!

    This is not possible without additional code. You can try to use the code someone posted here: http://www.sk23.co.uk/code-snippets/php/highlight-current-post-category-in-wordpress-categories-widget-using-jquery-php/ . In single.php replace:

    
    get_header();
    

    with

    
    get_header();
    $post_categories = wp_get_post_categories(get_the_ID()); 
    $script_out = '';
    
    foreach($post_categories as $c):
        $cat = get_category( $c );
        $script_out .= "jQuery('.cat-item-".$cat->cat_ID."').addClass('current-cat');";
    endforeach;
    
    echo '<script>'.$script_out.'</script>';
    
    

    and then you can use the current-cat class to highlight the current category like:

    
    #top #wrap_all .current-cat{ color: #ff0000; }
    

    Cheers!
    Peter

    #251259
    This reply has been marked as private.
    #251983

    Hey!

    1) If the code doesn’t work you probably need to modify the category widget code somehow. I recommend to hire a freelancer if you’re not familiar with the widget/php code. WordPress and the theme does not support the “current category highlight” feature by default and thus I consider this request as customization which is beyond the scope of our free support forum.

    2) You can change the post title at the top easily. Insert this code into the enfold/functions.php file or into your child theme functions.php file:

    
    add_filter('avf_title_args', 'single_blog_page_title', 10, 2);
    function single_blog_page_title($args,$id) {
    $pt = get_post_type( $id );
    if('post' == $pt){
            $cat = get_the_category($id); 
            if(isset($category[0])) $args['title'] = $category[0]->cat_name;
    }
    return $args;
    }
    

    Cheers!
    Peter

    #253884

    I guess i look for another alternative then…the code i paste in functions didn’t change the title. :(

    Thanks anyway

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Blog categories highlighted on the sidebar’ is closed to new replies.