How can I switch pages?

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?

Topic templates page-specific-settings pages menus Wordpress

Category Web


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:

    /restaurant-a/salads

and

    /restaurant-b/salads

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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.