WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problem creating custom menus for different category pages (3 posts)

  1. pongo
    Member
    Posted 1 year ago #

    I am currently developing a website for someone and I am having some issues with getting different menus to only show up on certain category pages. (e.g menu 1 on the about page, and menu 2 on the contact page and if the category isnt mentioned to not show a menu).

    I have tried searching for solutions and experimenting with the code but since my php knowledge is limited I am still having trouble. I think there is something wrong with my if/else statements.

    My code is -

    <?php if (is_category('currentlyavailable'||'image-gallery'||'about'||'map'||'contact')): ?>
    Currently Available

    <div id="firstpane" class="menu_list">
    <p class="menu_head">MtR</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'MR' )); ?>
    </div>
    <p class="menu_head">AtF</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'AF' )); ?>
    </div>
    <p class="menu_head">MtC</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'MC' )); ?>
    </div>
    <p class="menu_head">FtC</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'FC' )); ?>
    </div>
    </div>

    <?php elseif (is_category('how-to-care'||'walkingdd')): ?>
    Choosing a Walk

    <div id="firstpane" class="menu_list">
    <p class="menu_head">WF</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'WhF' )); ?>
    </div>
    <p class="menu_head">ST</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'SIAT' )); ?>
    </div>
    </div>

    <?php elseif (is_category('comingsoon')): ?>
    CS

    <div id="firstpane" class="menu_list">
    <p class="menu_head">CSJ</p>
    <div class="menu_body">
    <?php wp_nav_menu( array('menu' => 'TCDSJ' )); ?>
    </div>
    </div>

    <?php endif; ?>

    Right now the first menu 'currently available' is the only one showing, and comes up on all of the category pages except the homepage. If anyone is able to help with this I would really appreciate it.

  2. jonradio
    Member
    Posted 1 year ago #

    As shown in one of the examples here:
    http://codex.wordpress.org/Function_Reference/is_category
    the correct syntax for that first if statement is:
    if (is_category( array( 'currentlyavailable', 'image-gallery', 'about', 'map', 'contact' )))

  3. pongo
    Member
    Posted 1 year ago #

    Wow such a simple mistake, Thank you so much! :)

Topic Closed

This topic has been closed to new replies.

About this Topic