Normal WordPress behavior is for widget items to appear on all website pages. Widget logic allows you to create sidebar widgets that only appear on the pages you want them on. This can be helpful for a multitude of situations, for example, creating custom menus that only appear next to the pages you specify.
Use the following steps to create a submenu for any page:
- From the menu editor, create a new menu using the ‘create new menu’ link.
- Name the menu something relating to the page it will appear on.
- Add all the pages you would like to appear on this menu and click ‘save menu’ or ‘create menu’ your completed menu should look something like this:
- You now have a menu that can be attached to any page you specify. To attach it you will need to navigate to Appearance>widgets.
- From the left side of widgets editor, click and drag the item ‘custom menu: stacked pills’ into the ‘primary sidebar’ area. You will probably want to place it at the very top.
- At first placement the settings for this new widget will be empty, you will need to configure the settings as follows (refer to image below)
- Write a title for your submenu widget
- Select the menu from the dropdown that you just created in the menu editor.
- Enter the following code: is_page(‘your-page’) replace ‘your-page’ with the permalink for the page you want this new item to appear beside.