• Hi,

    I have been playing around with the wp_nav_menus() function. Somehow the function doesn’t return the current-* attributes like current-menu-item. I have been looking forever and it seems that I am doing something wrong.

    I use a custom theme, and made a menu in the admin panel. I use the regular function to call the menu, no tweaks or walkers etc. It shows the items, even the child-items, but it doesn’t pass through the classes that I want…

    Anyone?

    Thanks!

    Tom

Viewing 4 replies - 1 through 4 (of 4 total)
  • When you created the custom menu, did you actually add the items from the “Pages” or “Categories” metabox, or did you add them as custom links?

    Thread Starter Bomtuurman

    (@bomtuurman)

    Hi,

    I added different ones, none of them seem to work. Neither if I do only ‘pages’ for example.

    It outputs all the menu items, even the sub-menu’s. But none of them get the ‘current’ css classes ??

    T.

    I don’t think there will normally be a class of “current” applied. Instead, based on the tests I just ran, the current item gets a class of “current-nav-item”, “current_page_item” and/or “current-menu-item”. Also, that class is applied to the <li> tag rather than the link itself.

    Thread Starter Bomtuurman

    (@bomtuurman)

    Hi again, tnx for your reply.

    This is the output I get. The menu structure only contains pages:

    <ul id="custom-nav" class="custom-nav"><li id="menu-item-322" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-322"><a rel="Test" href="https://localhost/weer-in-zweden">weer-in-zweden</a></li>
    <li id="menu-item-326" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-326"><a href="https://localhost/zweden-fotos">zweden-fotos</a></li>
    <li id="menu-item-328" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-328"><a href="https://localhost/zweedse-kroon">zweedse-kroon</a>
    <ul class="sub-menu">
    	<li id="menu-item-327" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-327"><a href="https://localhost/evenementen">evenementen</a></li>
    </ul>
    </li>
    </ul>

    If I navigate to one of the pages in the menu it doesn’t output the additional classes.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_nav_menus() doesn't return current-page-item’ is closed to new replies.