• Resolved dpolcino

    (@dpolcino)


    I have Adv. Menu highlighting beautifully on all my levels (categories, sub-categories, pages) EXCEPT on a single-post page, I lose all ancestors, parents, main category highlights. I believe this is a newer WordPress fix that isn’t implemented in your plugin? My main menu still has the proper css classes like ‘current-parent’ etc.

    So any easy way to add some extra code to attach classes to these key types?

    Thanks

    http://wordpress.org/extend/plugins/advanced-sidebar-menu/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hello dpolcino,

    On a single post page, there are no parents or children to add classes to.
    Posts do not support assignment to parents like pages and categories do.

    The best you can do is target the category by id which is added to a class like ‘cat-item-11’.

    Hope this helps.

    Cheers.

    Thread Starter dpolcino

    (@dpolcino)

    Thanks, yes, I figured that was the case.
    Can you explain this a little more if you get a chance “..category by id which is added to a class like ‘cat-item-11’?

    I’m open to hardcoding for these sections, just haven’t figured out quite how to do it!

    Plugin Author Mat Lipe

    (@mat-lipe)

    Certainly,

    If you look at the menus output when you are on a single post page, you will see in the li items there is a class like cat-item-11 for example.

    <ul class="parent-sidebar-menu">	<li class="cat-item cat-item-1"><a href="http://wordpress.loc/category/uncategorized/" title="View all posts filed under Uncategorized">Uncategorized</a>
    </li>
    <ul class="child-sidebar-menu">	<li class="cat-item cat-item-11"><a href="http://wordpress.loc/category/uncategorized/under-uncategorized/" title="View all posts filed under Under Uncategorized">Under Uncategorized</a>
    </li>
    </ul><!-- End #child-sidebar-menu --></ul>

    Each category list item is given a class with the id of the category. So if the link if for a category with an id or 11 the class will be cat-item-11.

    The category id will not change from post to post so you can add css once and it will carry throughout the site.

    Thread Starter dpolcino

    (@dpolcino)

    Thanks! I think I’m getting somewhere. I put this in my template’s header file and it does generate what I need, it’s just not applying to the menu item. Probably a small error on my part (not quite targeting the class depth?):

    <?php
    if (in_category(‘noise’)){ $current = ‘page-item-17’; }
    elseif (in_category(‘studio-know-how’)){ $current = ‘cat-item-26’; }
    elseif (in_category(‘cool-gear’)){ $current = ‘cat-item-27’; }
    elseif (in_category(‘the-sessions’)){ $current = ‘cat-item-28’; }
    ?>
    <style type=”text/css”>
    .<?php echo $current; ?> {
    color: #000 !important;
    }
    </style>

    Plugin Author Mat Lipe

    (@mat-lipe)

    Here is something to try.
    Change your style code to this:

    <style type="text/css">
    .<?php echo $current; ?> a,
    .<?php echo $current; ?> a:visited{
    color: #000 !important;
    }
    </style>

    Hope this helps

    Thread Starter dpolcino

    (@dpolcino)

    Hah was just doing something similar:
    <?php
    if (in_category(‘noise’)){ $current = ‘page-item-17’; }
    elseif (in_category(‘studio-know-how’)){ $current = ‘cat-item-26’; }
    elseif (in_category(‘cool-gear’)){ $current = ‘cat-item-27’; }
    elseif (in_category(‘the-sessions’)){ $current = ‘cat-item-28’; }
    ?>
    <style type=”text/css”>
    #advanced_sidebar_menu_category-2 .<?php echo $current; ?> a {
    color: #000 !important;
    }
    </style>

    Take that WordPress!
    Thanks Mat.

    Plugin Author Mat Lipe

    (@mat-lipe)

    Lol.

    “Take that WordPress”. I love it! It may be my new tag line for the day.

    Cheers!

    Thread Starter dpolcino

    (@dpolcino)

    yup, yours works too of course and is better syntax.

    Thread Starter dpolcino

    (@dpolcino)

    caveat for anyone wanting to try this. Don’t add top level categories or else they’ll all hilite!

    resolved

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Menu Highlights on single post page’ is closed to new replies.