Use Static Navigation Menu in Wordpress

 Now we will remove dynamic menu and use static menu so remove dynamic menu functionality.

So for adding current menu class when active add below code in static menu 

 <li <?php if(is_page('about-us')) echo 'class="current-menu-item"' ?>><a
                href="<?php echo site_url('/about-us')  ?>">About Us</a>
            </li>

and also if we click page link of child page then also highlight parent page so modify above code

 <li <?php if(is_page('about-us') || wp_get_post_parent_id(0) == 15) echo 'class="current-menu-item"' ?>><a
                href="<?php echo site_url('/about-us')  ?>">About Us</a>
            </li>

Note wp_get_post_parent_id(0) means check current page parent.

save and check


Comments

Popular posts from this blog

Basics Of PHP

Creating App.js for Node Application

WordPress Full Guide For Developer