M
M
mrWan2018-02-10 01:49:48
WordPress
mrWan, 2018-02-10 01:49:48

I display my custom menu. The class for the active section is not added in the footer, what's the matter?

In the header, a class is added for the active section, but this class is not added
in the footer. In the header and in the footer, I add the menu like this:

if (function_exists('wp_nav_menu')) {
        wp_nav_menu(array('fallback_cb' => 'custom_menu','theme_location' => 'custom-menu', 'container' => 'ul','menu_class' => 'menu'));
      }

in functions.php file:
if (function_exists('register_nav_menus')) {
  register_nav_menus(
    array('custom-menu' => __('Custom menu'))
    );
}

function custom_menu() {
  echo '<ul>';
  wp_list_pages('title_li=&');
  echo '</ul>';
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mrWan, 2018-02-10
@mrWan

I have done this for the client so far:

if ($('#menu-menu-1 .menu-item-147').is('.current-menu-item')) {
     $('#menu-menu-2 .menu-item-147').addClass("current-menu-item");
  }

I know, this is the most ruthless way =) but what to do =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question