• I would like to add pages that do not appear as items in the top menu in the TwentyTwelve theme. Instead, I will link to these pages on other pages that appear in the top menu.

    I looked a bit around for a solution, and somewhere it was suggested that pages could be excluded via their IDs, using wp_list_pages() (see http://codex.wordpress.org/Function_Reference/wp_list_pages#Exclude_Pages_from_List ). However, I did not quite understand where this should be executed.

    So could someone please be explicit about how to exclude a specific page from appearing in the top menu?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You can simply create the pages and remove them from the menu – see:

    http://codex.wordpress.org/Appearance_Menus_Screen

    I do what you are asking about by making posts at the Dashboard and not having them display anywhere, then add the post’s links wherever I want them on the pages in the menus.

    the best and easiest way is as @wpyogi suggested.

    if you want to customize the theme to exclude pages from the top menu,
    start by creating a child theme of Twenty Twelve; http://codex.wordpress.org/Child_Themes

    Twenty Twelve uses ‘wp_page_menu()’ as a fallback if the custom menu is not activated; this needs to be influenced in functions.php;

    add a new functions.php into the child theme’s folder; make sure to have the <?php at the start;

    add this code (the numbers are the page IDs of the pages you want to exclude):

    function twentytwelvechild_page_menu_args( $args ) {
    		$args['exclude'] = '2,4,37';
    	return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentytwelvechild_page_menu_args', 20 );

    http://codex.wordpress.org/Function_Reference/wp_page_menu

    Thread Starter jakobrosenkrantz

    (@jakobrosenkrantz)

    You can simply create the pages and remove them from the menu – see:

    http://codex.wordpress.org/Appearance_Menus_Screen

    Thanks, this did the job; I created a custom menu and added the pages I want to appear in the menu. Excluding the page I did not want in the menu in this custom menu quite naturally did the job:-)

    the best and easiest way is as @wpyogi suggested.

    if you want to customize the theme to exclude pages from the top menu,
    start by creating a child theme of Twenty Twelve; http://codex.wordpress.org/Child_Themes

    Twenty Twelve uses ‘wp_page_menu()’ as a fallback if the custom menu is not activated; this needs to be influenced in functions.php;

    add a new functions.php into the child theme’s folder; make sure to have the <?php at the start;

    add this code (the numbers are the page IDs of the pages you want to exclude)…

    I already made a child theme, so thanks also for this suggestion. Is this in any way a better way to exclude pages?

    As I see it, when all I want is to exclude one or more pages, the procedure described above is simpler. But if more changes, e.g. customization of the design of the menu, is needed the changes in functions.php are required. Is that correct?

    Is this in any way a better way to exclude pages?

    no – just different.

    as I already mentioned, working with the custom menu is the best option.

    But if more changes, e.g. customization of the design of the menu, is needed the changes in functions.php are required.

    no – once you work with the custom menu, you can ignore that particular bit in the functions.php.

    alchymth
    Thanks for that code it’s exactly what I’m looking for but I’m confused.
    There are two bits of code in that php, the second starting with ‘add_filter’. It ends with …args’, 20);
    Is the number 20 also a page number? If not what does it do?
    Thanks
    Kevin

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘TwentyTwelve: Add page that does not appear in the top menu’ is closed to new replies.