How to exclude pages from wordpress menu without plugin

How to exclude pages from wordpress menu without plugin

In this tutorial we will show you How to exclude pages from wordpress menu without plugin. We given simple code for adding to your theme file which will remove pages from menu.

How to exclude pages from wordpress menu without plugin

Normally when we are creating wordpress theme for showing the pages we code as follows

<?php wp_page_menu('show_home=1&amp;menu_class=page-navi&amp;sort_column=menu_order'); ?>
How to exclude pages from wordpress menu without plugin
How to exclude pages from wordpress menu without plugin

As per this code all pages will get displayed in menu. For showing selected pages check the page id.

and then use following code.

<?php 
wp_page_menu('show_home=1&amp;exclude=5,9,23&amp;menu_class=page-navi&amp;sort_column=menu_order'); 
?>

You are able to see the I added the exclude parameter in wordpress method.
Your selected page id for excluding from menu, you need to just put there with comma separated.

Put this code in your header.php file for showing the menu. You are able to exclude the pages from wordpress menu

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “How to exclude pages from wordpress menu without plugin”

Leave a Reply

Your email address will not be published.