• Hi there,

    Say I have the categories:

    Cooking
    Photography
    Family

    I want to have all these in 1 blog, but on each category, have different sidebars. So on the cooking sidebars, I would have a different ad, some images of the latest recipes, etc. But then all different items on the Photography section.

    I know how to add dynamic sidebars, but what would I title them to coordinate with specific categories? sidebar-cooking.php?

    Thanks for the help in advance!

Viewing 1 replies (of 1 total)
  • let’s say you have 4 sidebars:

    sidebar-default.php.
    sidebar-cooking.php,
    sidebar-photography.php
    sidebar-family.php.

    In your sidebar.php, you can do this:

    if (is_category('5') || in_category('5') ){
      include('sidebar-cooking.php');
    
    } elseif (is_category('6') || in_category('6') ){
      include('sidebar-photography.php');
    
    } elseif(is_category('7') || in_category('7') ){
      include('sidebar-family.php');
    
    }else{
      include('sidebar-default.php');
    }

    The numbers correspond to a specific category in wordpress.

    You can also read up on Conditional Tags:https://codex.www.ads-software.com/Conditional_Tags

Viewing 1 replies (of 1 total)
  • The topic ‘Different sidebars for different categories’ is closed to new replies.