WordPress.org

Ready to get started?Download WordPress

Forums

Using conditional tags to display different menus (6 posts)

  1. dhobeika
    Member
    Posted 3 years ago #

    Hi all,

    I am working on a website for someone who does not like drop-down menus. On the top navigation, there is a row of menu items that will appear across the top of every page. There is also a second menu that goes down the sidebar of each page, but the sidebar menu needs to display different items depending on what page you are on:

    http://www.fitnessarts.org/new

    As you can see when you click on Home, About, or Studio from the top menu, I have used widget logic to set it up so that different menus display on each of these pages using the conditional tag is_page('page-name-goes-here'). However, I also want the menus to display when you click on any of the subpages along the sidebar of each of those sections.

    I have tried using the conditional tags is_page( array(139, 133, 137) ) and is_page( '139', '133', '137' ) where the numbers are the different page numbers for each section but that didn't work.

    Does anyone have any suggestions for conditional tags to display a series of different pages, or a better way to do this?

    Any advice would be appreciated.

  2. dhobeika
    Member
    Posted 3 years ago #

    Does anyone have any ideas on this?

  3. lockettpots
    Member
    Posted 3 years ago #

    Could you use the List Pages Shortcodes plugin in conjunction with a text widget?

    http://wordpress.org/extend/plugins/list-pages-shortcode/

  4. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    You can do it entirely via CSS, and calls to wp_list_pages().

    I use this technique in my Oenology Theme. You are welcome to borrow, steal, and modify the code to suit your needs. :)

    Here's my template output.

    Here are the CSS definitions.

  5. dhobeika
    Member
    Posted 3 years ago #

    Thanks for the help.

    Lockettpots -- it looks as though those shortcodes are only to list pages in the content of a page and not the sidebar. I guess I could try making a new template for each page and call up the code in the sidebar, but some of the menus contain categories so I don't think this will work since I need to be able to call the custom menu widgets.

    Chip -- I am looking at what you sent and I am completely self-taught in PHP and CSS (just from reading tutorials)and I am not sure how to tweak the code to get the different menus on the different pages and their children... can you provide further guidance if you have a free moment?

    Thanks again for your replies!

  6. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    @dhobeika: the best guidance I can give is the working code examples that I linked.

Topic Closed

This topic has been closed to new replies.

About this Topic