• Hi there. This is probably very simple, however I’m not having any joy. How is it possible to have a different menu on each page?

    I have used the following PHP code.

    <?php if( is_page('Home' ) ) get_sidebar('two');
    else if( is_page('Ministry' ) ) get_sidebar('three');
    else if( is_page('Events' ) ) get_sidebar('four');
    else if( is_page('Youth & Children' ) ) get_sidebar('five');
    else if( is_page('Community & Support' ) ) get_sidebar('six');
    else if( is_page('Services' ) ) get_sidebar('seven');
    else if( is_page('Contact' ) ) get_sidebar('eight');
    else get_sidebar();?>

    [Please post code snippets between backticks or use the code button.]

    Firstly is this correct and secondly, is there another way of achieving what I’m trying to do.

    Your help would be very grateful, as I’m on a deadline and this would definitely help get things moving.

    Kind regards

    Art

Viewing 3 replies - 1 through 3 (of 3 total)
  • Firstly is this correct

    Well, there’s nothing wrong with other than the fact that else if should be written as elseif in PHP.

    secondly, is there another way of achieving what I’m trying to do.

    You could create custom page templates for each of your pages and call the correct sidebar via the template. But that wouldn’t be any easier than what you are currently doing.

    Thread Starter art42

    (@art42)

    Thank you for getting back to me.

    I’m glad to see that the code is correct.

    However the only one that works is the first, Home page, the other do not, and it appears to be going straight to the final line in the coding.

    I have created the different sidebars, with each their own menus and links.

    Here’s an example of sidebar-3.php

    <li id=nav>

    Please post code snippets between backticks or use the code button.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different Menu for Different Page’ is closed to new replies.