I need to create a page in my site that I am able to access via url, but that won't be included in any of the navigation menus which are generated using wp_list_pages()
on my site.
How can I accomplish this?
I need to create a page in my site that I am able to access via url, but that won't be included in any of the navigation menus which are generated using wp_list_pages()
on my site.
How can I accomplish this?
The other option is to convert from wp_list_pages to the new custom menus. When using custom menus only pages you add to the menu will be included.
You're in luck, there's a filter. See this line inside wp_list_pages()
:
$r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );
So, just hook into wp_list_pages_excludes
:
// add some new page ids to the exclude list
function my_banned_pages( $exclude_array ) {
return array_merge( $exclude_array, array( 12, 45 ) );
}
add_filter( 'wp_list_pages_excludes', 'my_banned_pages' );
just pass a flag to the wp_list_pages function call. All you need to do is get the page ID you want to exclude. See the example on the codex page listed below. http://codex.wordpress.org/Function_Reference/wp_list_pages#Exclude_Pages_from_List