How to Exclude Pages from the WordPress Page Menu

Excluding pages from a menu generated by wp_list_pages() is easy. You don’t have to add another plugin to the pile in order to do it.

This is a handy snippet that you’ll use over and over again. Simply add this to your theme’s functions.php file:

{code type=php}
// add page ids to the exclude list
function my_banned_pages( $exclude_array ) {
return array_merge( $exclude_array, array( 4, 17 ) );
add_filter( ‘wp_list_pages_excludes’, ‘my_banned_pages’ );

Change the numbers in the array to the page ID’s that you want to exclude.