WordPress.org

Forums

different sidebars for individual pages (7 posts)

  1. EricAlmighty
    Member
    Posted 10 years ago #

    I have been wondering...I know it's possible to change the sidebar to display different information by changing the PHP "get sidebar" code on any template file. Is it possible to do this for static Pages created in the WordPress admin area? I'd like to display some info about me on the sidebar on my Bio page, some info on my graphics and what I do to make them on my Graphics page, etc...

    I have made up another sidebar PHP file so that's not an issue. The problem is when I call that sidebar into the Page Template EVERY page gets the sidebar and I want each Page to have a different sidebar. Is this possible and if so can how do I go about doing this?

  2. moshu
    Member
    Posted 10 years ago #

    You could use conditional tags to display different sidebars.

  3. EricAlmighty
    Member
    Posted 10 years ago #

    I've looked over the Conditional Tags. I might not be looking at the right thing...would I use any if/else functions? Exactly what tags should I be looking at and where do I use them?

  4. moshu
    Member
    Posted 10 years ago #

    Yes, there should be if/else stuff (don't ask me, I am a moron when it comes to write PHP code :)
    You should look at these tags (depending on your settings)
    is_page('42')
    When Page 42 is being displayed.
    is_page('About Me')
    When the Page with Title "About Me" is being displayed.
    is_page('about-me')
    When the Page with Page Slug "about-me" is being displayed.

  5. EricAlmighty
    Member
    Posted 10 years ago #

    alrighty we are truly getting somewhere here...so if I add an if/else function for each page using the COnditional Tags i should get a different sidebar? I'm not too good with PHP myself lol

  6. moshu
    Member
    Posted 10 years ago #

    Yes, that's the idea. If is_page(x) - where x is the page_id # - include sidebar1.php, ifelse page(53) include sidebar.2php etc...
    There is an example in this thread http://wordpress.org/support/topic.php?id=29434#post-173621
    with if statements... although it's about different stylesheets for categories, the syntax is the same. I hope :)

  7. EricAlmighty
    Member
    Posted 10 years ago #

    YES! That got it working! For now at least. I only applied the if to one page to test it but now I'll try and make all the sidebars and apply them similarly. Thanks a bunch for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags