Top

Daily Tip: How to Exclude Pages from the WordPress Page Menu

September 25, 2010

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:

// 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.

Tweet This Post

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.