One of my website visitors has requested to share a tutorial which describes how to create specific menus in a particular page. Here is the question “Can I specify different menus for the different page in WordPress ?” like I have pages A, B, C, D and I have menus menu1, menu2. I want page A, B to load menu1 and C, D to load menu2.
First create multiple menus like menu1, menu2, and menu3 and the respective page in menus and save. Copy the below code snippets and add at the end of the functions.php file.
1 2 3 4 5 6 7 8 9 10 11 12 | <?php if(is_page(array('1','2'))) { wp_nav_menu( array('menu' => 'menu1' )); } else { wp_nav_menu( array('menu' => 'menu2' )); } ?> |
I hope this tutorial helps you, if you have any questions regarding WordPress, then feel free to put your comments in below comment section. Do you like & share this article with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: display a menu on certain pages only, wordpress custom menu only on certain pages, wordpress display menu on certain pages, wordpress menu on certain pages, wordpress menu only on certain pages, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials, wordpress tutorials for beginners