current-menu-item class is not added

Question

Trying to style the active class of my navigation menu on my one-page theme, I have noticed that wordpress does not assign the current-menu-item class.
Why is this happening? Can you help me?

It is just a one-page theme, so the links in the page menu point to the sections on the same page.

in my header.php:

<?php
wp_nav_menu( array(
'theme_location' => 'menu-2',
'menu_class' => 'nav__menu js-nav__menu',
) );
?>

in my function.php:

if ( ! function_exists( 'cafecoders_child_setup' ) ) :

    function cafecoders_child_setup() {

            'menu-2' => esc_html__( 'Main menu cafecoders-child', 'cafecoders-child' ),
        ) );        
    }
endif;
add_action( 'after_setup_theme', 'cafecoders_child_setup' );
0
, Antonino Lattene 3 years 2019-12-04T10:04:06-05:00 0 Answers 87 views 0

Leave an answer

Browse
Browse