• Hi,

    How could i add a menus depending on the page? The sidebar.php has a certain conditions and i’d like to use similar on my own menus.

    I’d like to be able to:
    -Show menu on certain pages <– related to that particular page
    -Have a few different menus for different pages

    Is this possible / easy to do?

    THANKS!

    PS. I’m thinking of using this as CMS.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Each page has an ID value, which you can see under the Manage tab. So if you want a certain menu for the page with ID 4, you could do something like the following:
    if (4 == $id) {
    [echo menu]
    }

    What would you piece of code would you use so that the sidebar does not display on a certain page??
    thank you

    I’m not sure this is the best solution but faced with the same problem I resolved it using a second template and replacing
    < ? php get_sidebar(); ? >
    with
    < ? php include( TEMPLATEPATH . ‘/different sidebar/sidebar.php’); ? >
    after creating a directory named “different sidebar” with sidebar.php file in it.
    You can repeat the operation as many times as you wish.
    (delete the spaces to get it right)

    You can use CSS and filo’s suggestion to NOT display a menu on a certain page. In your template for that page, just set your menu (whatever it is in your stylesheet) set to “display:none;” and it won’t show on your page.

    doodlebee: doing that would remove it from all over the site.

    One solution might be to do the following.

    In your page.php file, just have <?php get_sidebar(); ?> as usual, but then in your sidebar.php file, you could do this:

    <?php if ( is_page('X') : ?>
    <!-- HTML for page with ID of X -->
    <?php elseif ( is_page('Y') : ?>
    <!-- HTML for page with ID of Y -->
    <?php elseif ( is_page('Z') : ?>
    <!-- HTML for page with ID of Z -->
    <?php else : ?>
    <?php get_sidebar(); ?>
    <?php endif; ?>

    You can repeat as many of those elseif statements as you like for all your various pages. The page ID can be found on Manage > Pages.

    >>doodlebee: doing that would remove it from all over the site.<<

    Not if you put it *only* in the CSS for the page you don’t want it to show up in…

    That’s true, but you’d have to specify the right link to the right CSS file, which would involve detecting which page you were on anyway ;D

    Well, I agree with that – but if it’s just one or two pages, you could simply put that CSS within an inline style directly on the template itself ?? If it’s quite a number of pages, then yeah, you’d *so* need detection!

    Thread Starter noobnoob

    (@noobnoob)

    Thanks for the replies!

    I’ll try the Maerk’s solution.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Showing a menu on certain pages’ is closed to new replies.