WordPress.org

Ready to get started?Download WordPress

Forums

Can I rotate Sidebars depending on the post catagory? (3 posts)

  1. actionbasic
    Member
    Posted 6 years ago #

    Hi all. I'm looking for a way to rotate a few different sidebars depending on what category the post being read is in. Here is my site:

    http://www.detour-mag.com

    as you can see the right sidebar is always the same no matter where you go in the site. Trying to get around that and have relevant info pulled in. I basically want to create a few "right sidebars" and have the ability to call the proper one for the post category. Is there an easy bit of code for this? or a plugin?

    Thanks in advance. Brandon

  2. Dgold
    Member
    Posted 6 years ago #

    I know of 2 ways, that you need to choose before you start on this tweak.

    (1) You make 1 giant sidebar.php with a bunch of Conditional Tags. You will need to study conditionals in the Codex to see how, it is explained there. Basically your sidebar would be,
    if category=1
    sidebar1
    sidebar1
    if category=2
    sidebar2
    sidebar2

    (2) Or you can use Category Templates. Look it up in the codex, it's pretty easy. Basically you just copy category.php and make:
    category-1.php
    category-2.php
    and, I think,
    sidebar-1.php
    sidebar-2.php

    then in category-1.php, change the sidebar call to sidebar-1.php

    and so on

    Hope this helps you find a direction to start making your sidebars

  3. actionbasic
    Member
    Posted 6 years ago #

    that helped quit a bit! thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic