WordPress.org

Ready to get started?Download WordPress

Forums

Changing content in sidebar depending on page (6 posts)

  1. PontusLundgren
    Member
    Posted 7 years ago #

    Hi.
    I'm currently porting my portfolio/blog to WordPress and I need to be able to change the content of my sidebar depending on which page I'm on. What's to most easiet way to do this?

  2. GOBLUE14
    Member
    Posted 7 years ago #

    Page Templates

    You can then replace the "get_sidebar" with an include to the sidebar you'd like to have, or no sidebar at all.

  3. PontusLundgren
    Member
    Posted 7 years ago #

    So, what I should do is to delete the snippet that fetches the sidebar in the footer template file and instead fetch it from the index file (through a new page, so to speak)?

  4. GOBLUE14
    Member
    Posted 7 years ago #

    Make a file for the particular sidebar you're looking for for a page, saving it in your ./wp-content/themes/ThemeFolder directory.

    Then on the page's template, yes, you'd replace the get_sidebar with <?php include('newsidebar.php') ?>.

  5. PontusLundgren
    Member
    Posted 7 years ago #

    But what if I want to keep the orginal sidebar on my blog page (since I have a home, portfolio, about and blog page)?

    Thanks for your help GOBLUE14! :)

  6. Leovenous
    Member
    Posted 7 years ago #

    Just run a conditional to see if it is the home page.

    http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page

    Use that determine which file to call, OR, as I do on one of my sites, I have a home page template that is different than my other page template, so in that case my homepage template calls one header while my other pages call a different header. That can be done with sidebars just as easily.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags