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.
FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.
FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.
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 IDs that you want to exclude.
Tags: