Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #11408


    Still got a little problem. I allready ask this here : but the topic allready closed. The code in my functions.php is working but when I click on the last link in the menu and go after that to another page, the last link still showing active. This is only happening for the last link. If I switich between other links it works fine. Suggetions?

    Thanks a lot!!


    Hi jorisvh,

    I’m not sure. You might want to include the code you have added and a link to the issue live in case anyone has a suggestion.




    Hey Devin,

    I am not sure what you mean? Right now it is just css code. Do I have to include it in my function.php?




    I think what Devin meant is that we would need to see a live example of this to test for ourselves. Or if you’re not comfortable with posting a link you can copy the HTML that WordPress generates as well as any custom CSS.

    Based on what you’re describing my guess is that the code in your functions.php is breaking on the last link. By that I mean when you click on the last link then another link the the current-menu-item is still listed as a class name for that last link.




    THis is my code in the functions.php

    add_filter('nav_menu_css_class', 'AddCurrentMenuItemClass',1,2);
    function AddCurrentMenuItemClass($classes,$item)
    $link = site_url().$_SERVER['REQUEST_URI'];
    if(strpos($link, $item->url) !== false)
    $classes[] = 'current-menu-item';
    return $classes;

    This is my css code:

    .current-menu-item a{
    color: #fe4e02 !important;

    And some HTML code of my menu:

    </div></div></div><!--mfunc get_sidebar("") --><!--/mfunc--><div class="sidebar sidebar1 box"><div class="inner_sidebar"><div class="box"><div class="main_menu main_menu_menu_manager"><div class="menu-main_menu-container"><ul id="menu-main_menu" class="menu"><li id="menu-item-227" class="menu-item menu-item-type-custom menu-item-object-custom first-child"><a href="?product=100-bamboo-orange"><strong class="cufon_headings">10’0? Bamboo Orange</strong></a></li>
    <li id="menu-item-228" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="?product=100-bamboo-blue"><strong class="cufon_headings">10’0? Bamboo Blue</strong></a></li>
    <li id="menu-item-229" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="?product=106-allround"><strong class="cufon_headings">10’6? Allround</strong></a></li>
    <li id="menu-item-247" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="?product=116-allround-blue"><strong class="cufon_headings">11’6? Allround</strong></a></li>
    <li id="menu-item-258" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item"><a href="?product=126-race-white"><strong class="cufon_headings">12’6 Race white</strong></a></li>
    <li id="menu-item-264" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="?product=126-race-blue"><strong class="cufon_headings">12’6? Race Blue</strong></a></li>
    <li id="menu-item-270" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="?product=100-isup"><strong class="cufon_headings">10’0 iSUP</strong></a></li>
    <li id="menu-item-449" class="menu-item menu-item-type-custom menu-item-object-custom"><a href="/accessories"><strong class="cufon_headings">Accessoires</strong></a></li>
    <li id="menu-item-461" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-177 current_page_item current-menu-item last-child"><a href=""><strong class="cufon_headings">Shopping cart</strong></a></li>






    Hi jorisvh,

    I’m not really sure. Having not written the code in your functions I’m just not familiar with what it is doing and how to fix whats happening.



Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘current page link color2’ is closed to new replies.