-
AuthorPosts
-
April 4, 2014 at 5:09 pm #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, 8 months ago by claraelisa.
April 7, 2014 at 10:34 pm #248515Hi 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, 8 months ago by David.
April 8, 2014 at 12:19 am #248543This reply has been marked as private.April 10, 2014 at 12:41 am #249493Hey!
Please adjust David’s code a bit and use it as following
#top .widget ul li.current-cat { background-color: #f5f5f5; }
Cheers!
YigitApril 10, 2014 at 6:44 pm #249886Hi!
Still not working :(What could it be?
April 11, 2014 at 2:14 am #250024Hey!
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,
YigitApril 11, 2014 at 3:31 pm #250260Thanks 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
April 14, 2014 at 9:24 am #250954Hey!
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!
PeterApril 14, 2014 at 7:16 pm #251259This reply has been marked as private.April 16, 2014 at 9:09 am #251983Hey!
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!
PeterApril 21, 2014 at 4:07 pm #253884I guess i look for another alternative then…the code i paste in functions didn’t change the title. :(
Thanks anyway
-
AuthorPosts
- The topic ‘Blog categories highlighted on the sidebar’ is closed to new replies.