How Do I Exclude a Page From a Menu in WordPress?

There are a few ways to exclude a page from a WordPress menu. One way is to use the filter function in the admin area. To exclude a page from the main menu, go to Appearance > Menus and add a new menu item with the name of the page you want to exclude.

To exclude a page from the sidebar menu, go to Appearance > Menus and add a new menu item with the name of the page you want to exclude. To exclude a page from the custom menus you create, add a filter in the custom menu item’s code. In the custom menu item’s code, add the following filter:.

add_filter(‘menu_item_exclude’, ‘my_custom_filter’);

To add a page to the excluded list, add the following filter to the custom filter:

remove_filter(‘menu_item_exclude’, ‘my_custom_filter’);

To remove a page from the excluded list, add the following filter to the custom filter:

remove_filter(‘my_custom_filter’, ‘menu_item_exclude’);

When you exclude a page from a WordPress menu, it will not show up in the main menu, the sidebar menu, or any of the custom menus you create.