How To Exclude Pages From WordPress Menus

There are times when a website owner creates needed pages for a WordPress website but wants or needs to exclude pages from WordPress menus.

WordPress menus are functional and they are important for site structure and navigation layout. In this article, I will show you two quick and easy ways to exclude pages from WordPress menus.

Exclude Pages From Menus Using Code

You can easily exclude WordPress menu pages using a combination of code and page IDs. Most of the time the code line you need to find and change for this will be located in the sidebar.php file, though it sometimes can be located in other files.

To access the sidebar.php file click on Appearance > Editor.

Click on appearance then editor to access sidebar.php file

This will take you to the website file’s page where you can access the sidebar.php file.

Click on sidebar.php to access the file

Open that file and locate the following code:[ht_message mstyle=”info” title=”” show_icon=”” id=”” class=”” style=”” ]

<?php wp_list_pages();?>

[/ht_message]

Replace that line of code with this line and save the changes.

[ht_message mstyle=”info” title=”” show_icon=”” id=”” class=”” style=”” ]

<?php wp_list_pages(‘exclude=7,17’ ); ?>

[/ht_message]

Please note that the ID numbers above in the line of code are page ID numbers. Those numbers are used in this example, but you would simply replace those page ID numbers with any pages you want to exclude from WordPress menus.

Exclude Pages From Menus Using a Plugin

Another simple way to exclude pages in a WordPress menu is to use the Exclude Pages From Menu Plugin.

This plugin provides an option in the page edit screen in the admin area that you can use to exclude pages from displaying in WordPress navigation menus.

First, you need to install and activate the plugin.

Install and activate exclude pages from menu plugin

There are no options and the setup is done. It is a lightweight and easy-to-use plugin that will easily exclude WordPress menu pages. Just go to any page you have and you will see a “Exclude pages from menu” box. Check the box to exclude the page when needed.

Check the exclude page from menu box when needed

As you can see both options provide you with a fast and simple way to exclude pages from WordPress menus. I hope this article has been helpful in showing you how easy it is to exclude pages from a WordPress menu when you need to.

What are some reasons you may want to exclude certain pages from menus? Do you prefer using the code option or the plugin option to complete this task?

1 thought on “How To Exclude Pages From WordPress Menus”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copy link