[resolved] Display different sidebars depending on current page (4 posts)

  1. zaqedc
    Posted 3 years ago #

    I have a sidebar.php and a second file I created (more or less and exact same except for the title) called sidebar-2.php. In page.php I edited the get_sidebar() bit to look like this:

    <?php if (is_page('405')){ get_sidebar('sidebar-2.php');} else { get_sidebar(); } ?>

    The object being that if a certain page was displaying, a different sidebar would appear. As it stands, when I navigate to the page specified, the normal sidebar just displays all the time.

    I am a complete beginner as far as PHP is concerned so if anyone has an idea of where I'm going wrong I'd appreciate it. thanks!

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    <?php if (is_page('405')){ get_sidebar('2');} else { get_sidebar(); } ?>


  3. zaqedc
    Posted 3 years ago #

    That's sorted it. I should read things more in depth before coming here and bleating about problems :) Thanks very much!

  4. Ray Doniel
    Posted 3 years ago #

    what about sub pages of the 405 (for example), how can I make so that it also calls the same sidebar

Topic Closed

This topic has been closed to new replies.

About this Topic