How to add a class in wordpress selected menu?

I want to add a class to highlight the selected menu in wordpress. I have done this in html by the following code.

<ul class="nav navbar-nav" >
    <li class="active-link"><a href="">Home</a></li>
    <li><a href="">About Us</a></li>

    <li><a href="">Our Services</a></li>

    <li><a href="">Case Studies</a></li>
    <li><a href="">contact</a></li>
</ul>

How can i do this in wordpress?

Related posts

Leave a Reply

2 comments

  1. used this code

    Add this line off code function.php

    add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
    function special_nav_class($classes, $item){
         if( in_array('current-menu-item', $classes) ){
                 $classes[] = 'active ';  // your new class
         }
         return $classes;
    }