WordPress.org

Ready to get started?Download WordPress

Forums

PLEASE: current-menu-item / current_page_item NOT working on custom pages. (6 posts)

  1. jucedupp
    Member
    Posted 3 years ago #

    Hi

    I have been reading and reading about this and I am ready to give up. Please. help me on this.

    It's simple:

    The CSS classes are fine.

    The problem is, that when I click on a sub-item in my sidebar:

    The post is rendered through single.php. Right.

    The problem is that in my top nav menu, the class "current_page_parent" or the class "current_page_item" or the class "current_page_ancestor" is NOT being added to the main menu

  2. example:
    When on a main menu item directly:

    <div id="access" role="navigation">
                    <div class="menu-header"><ul id="menu-main-menu" class="menu"><li id="menu-item-442" class="menu-item menu-item-type-custom menu-item-home menu-item-442"><a href="http://gcsa.camarahost.co.za/">Home</a></li>
    <li id="menu-item-249" class="menu-item menu-item-type-post_type current-menu-item page_item page-item-97 current_page_item menu-item-249"><a href="http://gcsa.camarahost.co.za/who-we-are/">Who We Are</a></li>
    <li id="menu-item-250" class="menu-item menu-item-type-post_type menu-item-250"><a href="http://gcsa.camarahost.co.za/what-we-do/">What We Do</a></li>
    
    <li id="menu-item-251" class="menu-item menu-item-type-post_type menu-item-251"><a href="http://gcsa.camarahost.co.za/our-work/">Our Work</a></li>
    <li id="menu-item-255" class="menu-item menu-item-type-post_type menu-item-255"><a href="http://gcsa.camarahost.co.za/blog/">Blog</a></li>
    <li id="menu-item-257" class="menu-item menu-item-type-post_type menu-item-257"><a href="http://gcsa.camarahost.co.za/news-press/">News & Press</a></li>
    <li id="menu-item-253" class="menu-item menu-item-type-post_type menu-item-253"><a href="http://gcsa.camarahost.co.za/contact/">Contact</a></li>
    </ul></div>

    AND THEN

    when on a post that is not renedered via the blog or hom page:

    <div id="access" role="navigation">
    				<div class="menu-header"><ul id="menu-main-menu" class="menu"><li id="menu-item-442" class="menu-item menu-item-type-custom menu-item-home menu-item-442"><a href="http://gcsa.camarahost.co.za/">Home</a></li>
    <li id="menu-item-249" class="menu-item menu-item-type-post_type menu-item-249"><a href="http://gcsa.camarahost.co.za/who-we-are/">Who We Are</a></li>
    
    <li id="menu-item-250" class="menu-item menu-item-type-post_type menu-item-250"><a href="http://gcsa.camarahost.co.za/what-we-do/">What We Do</a></li>
    <li id="menu-item-251" class="menu-item menu-item-type-post_type menu-item-251"><a href="http://gcsa.camarahost.co.za/our-work/">Our Work</a></li>
    <li id="menu-item-255" class="menu-item menu-item-type-post_type menu-item-255"><a href="http://gcsa.camarahost.co.za/blog/">Blog</a></li>
    <li id="menu-item-257" class="menu-item menu-item-type-post_type menu-item-257"><a href="http://gcsa.camarahost.co.za/news-press/">News & Press</a></li>
    <li id="menu-item-253" class="menu-item menu-item-type-post_type menu-item-253"><a href="http://gcsa.camarahost.co.za/contact/">Contact</a></li>
    </ul></div>

    This issue prohibits WordPress from being used where custom queries are involved.

    How can this be fixed? I use WP 3.01..

    Thanks

    Jacques

  • chodorowicz
    Member
    Posted 3 years ago #

    The 'current' classes in wp_nav_menu are so buggy in my experience that they're almost unusable - part of the problem probably comes from this bug:
    http://core.trac.wordpress.org/ticket/14053
    Hopefully it all gets better in WP 3.1

  • mrkeroppi
    Member
    Posted 3 years ago #

    Hope this helps anyone looking for this. My problem was having the current-menu-item class disappearing on any link other than the home page. I was using custom links in the menu panel to create my menu. The problem was using root relative links ( /product-page/men/ ) instead of the full link ( http://www.mysite.com/product-page/men/ ) works fine now.

  • DrLightman
    Member
    Posted 3 years ago #

    I'm having this problem too and the strange thing is it's working for all menu items excpet for one static page menu item, named "shop".

    Mostly are static pages, and some category links. All works expcte for mysite.com/shop/ that doesn't acquire the current-menu-item class.

  • DrLightman
    Member
    Posted 3 years ago #

    And as always happens, after I post, I find the cause of the issue.

    The template page was holding a query_posts call that was returing 0 posts polling froma category "shop", so this caused the menu item to not highlight with the current-menu-item class.

    Commenting the function call or adding a post to the category "shop" fixed this, don't ask me why...

  • willio
    Member
    Posted 3 years ago #

    I fixed it by adding categories (instead of pages) to the menu.

    http://portfoliography.com/blog/

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags