I have website for local restaurant and for menu there are separate pages (ex: salads, soups etc). Right now the second restaurant was opened and it has a separate menu.

What I want to do is to create some kind of switch - so user can select what restaurant he wants to see. And he can switch deserts page of restaurant A and restaurant B. How it should be done?

  • Please consider marking my answer as accepted. – Pim Sep 12 '18 at 16:03

If you do this with pages, you will either have to make two pages, or you can put it in the same page and only show the content of restaurant B when you click a button or link (for instance). This can be done with jQuery, for example. In the latter case you will have the same URL for the page.

There are many ways to go at this. You could also make parent pages "Restaurant A" and "Restaurant B" and have different sets of child pages with the same name. That way you will have a URL like:




There are many ways to achieve this, ranging from simple to complicated. A simple one may suffice in your case. Simply generate three different menus in the backend and display them depending on the page where you are:

if (is_home) wp_nav_menu (array('menu' => 'home'))
elseif (is_page (array('menu-a,deserts-a'))) wp_nav_menu (array('menu' => 'restaurant-a'))
elseif (is_page (array('menu-b,deserts-b'))) wp_nav_menu (array('menu' => 'restaurant-b'))

This should work perfectly on a site with just a few pages. If there are more pages you could get the array of pages by using get_children.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.