Exclude Pages from the menu In WordPress.



In WordPress, when we are Implementing the custom HTML into the WordPress, Suppose we have created the pages and don't want to display it in the menu. For this we can pass the one parameter named as exclude into the wp_list_pages function,

For this Navigate to the wp-content –> themes –> your_own_theme –>header.php

Search for the

<?php wp_list_pages('sort_column=menu_order&title_li='); ?>

and then add &exclude= page id’s separated with the comma(,)

like &exclude=10,11 where 10,11 are the page ids

Now the function look like this

<?php wp_list_pages('sort_column=menu_order&title_li=&exclude=10,11' ); ?>

Find below the Function Reference/wp list pages

<?php wp_list_pages( $args ); ?>
<?php $args = array(
'depth'        => 0,
'show_date'    => '',
'date_format'  => get_option('date_format'),
'child_of'     => 0,
'exclude'      => '',
'include'      => '',
'title_li'     => __('Pages'),
'echo'         => 1,
'authors'      => '',
'sort_column'  => 'menu_order, post_title',
'link_before'  => '',
'link_after'   => '',
'walker'       => '',
'post_type'    => 'page',
'post_status'  => 'publish'
); ?>