1666 posts
  • Has been part of the Envato Community for over 4 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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.

1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
mabuc says

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

1666 posts
  • Has been part of the Envato Community for over 4 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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.
1179 posts
  • Has referred 200+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+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 ) );
1666 posts
  • Has been part of the Envato Community for over 4 years
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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') ) : ?>

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by