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.
are you using a menu fallback? or the custom menu?
mabuc said
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.webdesignerart said
mabuc said
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 ) );
mabuc said
webdesignerart said
mabuc said
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') ) : ?>
