Hide certain pages from the menu
-
I would like to hide certain pages from the menu at the top of the page. I am using theme twentytwelve. Is there any way of doing this?
-
one possibility:
create a custom menu –http://codex.ww.wp.xz.cn/WordPress_Menu_User_Guide
http://codex.ww.wp.xz.cn/Appearance_Menus_Screenalternative (if you know the page IDs):
create a child theme (if you don’t have already), and add some code to functions.php in the child theme;example:
//exclude pages from default menu// function twentytwelvechild_page_menu_args( $args ) { if ( ! isset( $args['show_home'] ) ) $args['exclude'] = '2,675,838'; return $args; } add_filter( 'wp_page_menu_args', 'twentytwelvechild_page_menu_args' );Great, thank you – I will give it a go! 🙂
Great – thanks – works perfectly – only thing is I had to put it into the main functions.php – if I copied it into child folder website went blank.
editing the parent theme’s functions.php is counterproductive.
if this was your first code for a new functions.php in the child theme, then you need to start the file with a php tag
<?php(nothing before that whatsoever):i.e. a new functions.php in the child theme with only the suggested code would totally look like:
<?php //exclude pages from default menu// function twentytwelvechild_page_menu_args( $args ) { if ( ! isset( $args['show_home'] ) ) $args['exclude'] = '2,675,838'; return $args; } add_filter( 'wp_page_menu_args', 'twentytwelvechild_page_menu_args' );(the closing php tag is not needed)
OK much better – thanks 🙂
it is important to remember that the functions.php in the child theme adds to the parent theme’s functions. It does not replace it like a template would.
Or if you want to make it easier for a client to do this (not having to edit a functions.php) you could use a plugin called “Exclude pages from navigation” though I see it is not updated recently…
So the functions method might be your best bet.
The topic ‘Hide certain pages from the menu’ is closed to new replies.