different sec. menu's per page

  • Anonymous


    Here’s another one… Yes WP keeps me quite busy, but hey, isn;t that part of the fun??

    I’m trying to set up three different secondary custom menu’s. The header menu will remain the same throughout the page, but when you go to band or fans, I’d like to have a secondary (custom) menu displaying all sub-pages in the band or fan part (there’s third one called media)

    So looking around the forum I found this https://forum.graphene-theme.com/graphene-support/conditional-secondary-menu#post-7017

    I tried out the code displayed there and filled it all in, pasted in my hild-theme’s function page and this is the code I ended up with (yes, I’m learning)

    /* Register multiple secondary menus */
    register_nav_menus( array(
    'secondary-menu-band' => __( 'Secondary Menu (band)', 'graphene' ),
    'secondary-menu-media' => __( 'Secondary Menu (media)', 'graphene' ),
    'secondary-menu-fans' => __( 'Secondary Menu (fans)', 'graphene' ),
    ) );

    /* Conditionally display secondary menu */
    function graphene_multiple_secondary_menu( $args ){

    if ( is_page('band') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-band' ) );
    if ( is_page('jaap') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-band' ) );
    if ( is_page('muco') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-band' ) );
    if ( is_page('dimitry') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-band' ) );
    if ( is_page('media') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-media' ) );
    if ( is_page('music') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-media' ) );
    if ( is_page('pictures1') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-media' ) );
    if ( is_page('video') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-media' ) );
    if ( is_page('press1') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-media' ) );
    if ( is_page('fans') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-fans' ) );
    if ( is_page('forum-2') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-fans' ) );
    if ( is_page('remixes') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-fans' ) );
    if ( is_page('pictures') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-fans' ) );
    if ( is_page('videos2') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-fans' ) );
    if ( is_page('reviews') )
    $args = array_merge( $args, array( 'theme_location' => 'secondary-menu-fans' ) );
    return $args;
    add_filter( 'graphene_secondary_menu_args', 'graphene_multiple_secondary_menu' );

    in addition to that i’ve also made the secondary menu’s in the appearance->menu part

    It didn’t do anything… check http://www.twowaysociety.nl/hidden/

    So what am I doing wrong here?

    I also like to add the links to the three category archives I made in here, but can’t find the slugs



    Try using page IDs instead of page slug. Something like this,

    is_page(246) instead of is_page('fans')





    Changed all the slugs into ID’s, but it’s still not working. Hmm. I think I’m doing something wrong in the custom menu => theme locations

    I haven’t chosen a secondary menu there, just created the three named above. But if I choose one of them, the theme’s showing that one everywhere and I wanted to have different 2nd menu’s for different pages…

    Well, thanks for the help, at least now I know it’s not wrong in the function.php. Maybe (just thinking out loud, you must know I’m a noob) I should call the function to take place at the secondary menu hook… (plz don’t laugh too loud if I’m wrong). What do you think (and more important) how should I do that??



    Diving into the WordPress codex, getting my feet wet and all, I came across “lists”. What if I create this in my function.php

    <div id='second_navmenu_band>
    <?php wp_list_pages('include=9,231,237,235'); ?>

    and I’ll do the same for the fans and the media

    Then I’ll do this in style.css:

    #second_navmenu_band ul {margin: 0; padding: 0;
    list-style-type: none; list-style-image: none; }

    and will do the same for fans and media

    Now all I have to do is creating a header.php in my child theme and let the second_navmenu_band show up while someone is watching pages 9, 231, 237 & 235 and do the same for “second_navmenu_fans” and “second_navmenu_media” and their corresponding pages ***sighs***

    Do I think in the right way? Does anyone know how to get the right second_navmenu at the right moment? E.g. while watching page 9 second_navmenu_band shows up.

    (second_navmenu will be a secondary nevmenu under the headermenu….)


    Kenneth John Odle


    The functions file is only for functions, so including a <div> and a <ul> (and unclosed ones at that) will either do nothing or will only mess things up.



    Ok, so I was getting off track there… Thought it was a good alternative to the code above. Just noticed there was a good tutorial somewhere about the hooks. Maybe I’d see that first and see if that’ll help me out in some way or another. Any suggestion is welcome, even if it’s just to point me in the right direction.

    keep you all updated…



    Ok guys, after watching Josh’s action hook tutorials (both of ’em) I came up with the following. Don’t know if it will work, if any of you think I’m way off, please let me know 🙂

    I’ll put this in the child theme’s functions.php:

    function secondary_menu_listing(){


    <div id=secondary_menu_listed><? php
    if (is_page (array(9,231,237,235));
    wp_list_pages (include=9,231,237,235);

    if (is_page (array(14,121,124,119,104));
    wp_list_pages (include=14,121,124,119,104);

    if (is_page (array(246,230,252,254,259,257));
    wp_list_pages (include=246,230,252,254,259,257);
    <? php add_action ('graphene_before_content'); ?><? php

    Then in style.css I can make the <div> look nice using this

    list-style-type: none; list-style-image: none;

    And some padding and other style’s (maybe just copying the original secondary_menu css)

    Am I right this time???



    That’s not it, either. Got this error :

    “Parse error: syntax error, unexpected T_FUNCTION in /home/twowaysociety.nl/public_html/hidden/wp-content/themes/graphene-child/functions.php on line 3”

    I see now I forgot ” ) ” this one… and I used to be pretty good in math… Close all brackets…

    I’ll give it another go



    OK… that was not working either *sighs*, but since I don’t give up that easily, I gave it another go with this:

    if ( function_exists( 'register_nav_menus' ) ) {
    'secondary_menu_1' => 'Band Pages',
    'secondary_menu_2' => 'Media Pages'
    'secondary_menu_3' => 'Fans Pages'


    <? php

    if ( function_excists( 'secondary_menu_1')){
    ?><div id=secondary_menu_1>
    <? php wp_list_pages (include=' 9,231,237,235'); ?></div>

    <? php } ?>

    <? php

    if ( function_excists( 'secondary_menu_2')){
    ?><div id=secondary_menu_2>
    <? php wp_list_pages (include='14,121,124,119,104'); ?></div>

    <? php } ?>

    <? php

    if ( function_excists( 'secondary_menu_3')){
    ?><div id=secondary_menu_3>
    <? php wp_list_pages (include='246,230,252,254,259,257'); ?></div>

    <? php } ?>

    <? php

    if (is_page(array('9,231,237,235')));
    function ('secondery_menu_1')

    if (is_page(array('14,121,124,119,104')));
    function ('secondary_menu_2')

    if (is_page(array('246,230,252,254,259,257')));
    function ('secondary_menu_3')

    <? php add_action ('graphene_before_content'); ?>

    resulted in the following error: `Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)’ in /URL/graphene-child/functions.php on line 7

    It feels like I’m getting closer, but not sure if that’s really the case…



    I haven’t tested your code, so I don’t know if it’s correct or not.

    However, you don’t want to end php and then begin it again. For example, take out all the ?> <?php areas in the code.

    And this is a problem:

    php add_action ('graphene_before_content');

    Check out the codex on how to properly use action and filter hooks:


Viewing 10 posts - 1 through 10 (of 19 total)

  • 1
  • 2
  • You must be logged in to reply to this topic.
Graphene Themes Forum