Wordpress current-menu-ancestor current-menu-parent class why showing in Nav?

1749 posts
  • 4 Years of Membership
  • Beta Tester
  • Collector Level 2
  • Exclusive Author
webdesignerart
says

Hi guys i made class for current menu item its work fine but on home my product page like automatically add current-menu-ancestor current-menu-parent class why its showing on menu these extra class. I already add home page link its work fine and asigning current page link but the prodcut page is also highlighting in home page.

So anyone idea which things maybe causing this issue.

1180 posts
  • Affiliate Level 5
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
+2 more
mabuc
says

are you using a menu fallback? or the custom menu?

1749 posts
  • 4 Years of Membership
  • Beta Tester
  • Collector Level 2
  • Exclusive Author
webdesignerart
says

are you using a menu fallback? or the custom menu?
$walker = new My_Walker;
            wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu, 'container' => false, 'walker' => $walker ) );
Menu fallback.
1180 posts
  • Affiliate Level 5
  • Author Level 5
  • Collector Level 2
  • Exclusive Author
+2 more
mabuc
says


are you using a menu fallback? or the custom menu?
$walker = new My_Walker;
            wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu, 'container' => false, 'walker' => $walker ) );
Menu fallback.

try this: I hope this helps :)

function menu_fallback() {
        if(is_front_page()){ $class="current_page_item"; }
        ?>
        <div class="menu">
            <ul>
                <li class="<?php echo $class; ?>">
                    <a href="<?php echo home_url(); ?>">Home</a>
                </li>
                <?php wp_list_pages(); ?>
            </ul>
        </div>
        <?php
    }
$walker = new My_Walker;
            wp_nav_menu( array( 'fallback_cb' => 'menu_fallback', 'menu' => $nav_menu, 'container' => false, 'walker' => $walker ) );
1749 posts
  • 4 Years of Membership
  • Beta Tester
  • Collector Level 2
  • Exclusive Author
webdesignerart
says



are you using a menu fallback? or the custom menu?
$walker = new My_Walker;
            wp_nav_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu, 'container' => false, 'walker' => $walker ) );
Menu fallback.

try this: I hope this helps :)

function menu_fallback() {
        if(is_front_page()){ $class="current_page_item"; }
        ?>
        <div class="menu">
            <ul>
                <li class="<?php echo $class; ?>">
                    <a href="<?php echo home_url(); ?>">Home</a>
                </li>
                <?php wp_list_pages(); ?>
            </ul>
        </div>
        <?php
    }
$walker = new My_Walker;
            wp_nav_menu( array( 'fallback_cb' => 'menu_fallback', 'menu' => $nav_menu, 'container' => false, 'walker' => $walker ) );

Thanks for your help, but it will not working in my senario because i am using jquery mega menu plugin which call through widget option.

 if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('main_mega_menu') ) : ?>
by
by
by
by
by
by