• I would like to know if I can remove the link to the current item of the menu.

    I know that there is a class “current-menu-item” added to the active item of the menu but I’d like to remove completely the link inside the that element. I want something like:

    <li class="current-menu-item menu-item">Home</li>
    <li class="menu-item"><a href="#">About us</a></li>

    Notice that the Home element has no link and cannot be clicked. Is it possible somehow to do this?

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am new in wordpress, 1 month ago.
    I am experiencing the same issue.
    Did you get a response?

    Regards,

    This can easily be accomplished with jQuery:

    jQuery(document).ready(function($){
    var caption = $(‘.current-menu-item a’).text();
    $(‘.current-menu-item’).html(caption);
    });

    just make sure you first enqueue the jQuery script, which is already included in WordPress.

    I solved this problem with creating my own walker class, which extends Walker_Nav_Menu. Put this code into functions.php file of your theme.
    P.S. Maybe it’s not perfect, but can be useful.

    http://pastebin.com/DaibZ4BG

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wp_nav_menu remove link from highlighted item’ is closed to new replies.