WordPress add class to specific menu item

I have an onepage template. Menu has Home, Services, Blog, Contact etc and working with <div id="blog">. If someone clicks menu item “Blog” goes to domain.com/#blog. If click on blog title goes to domain.com/blog/blog-title. In this page i want an active class in menu item “Blog”. This is my code

add_filter('nav_menu_css_class' , 'my_nav_special_class' , 10 , 2);
function my_nav_special_class($classes, $item){
    if(( is_page_template( 'page-blog.php' ) ) && ($item->title == 'BLOG')) {
        $classes[] = 'active';
    }   
    return $classes;
}

While loading page menu item “Blog” is active. When stops loading menu item “Home” is active.

Read More

How can i keep class="active" only in menu item “Blog” ?

Related posts