Custom sidebar for Archives & Category pages

resolved (4 posts) (2 voices)

  1. Hello,
    I have two custom sidebars in my inFocus theme, but Archives and Category pages (when clicking on tags in top metadata, or on categories in breadcrumbs) show the default sidebar of the theme (see example on my site: http://greyarium.com/category/people/)

    Where in the code should I specify to use one of my custom sidebars?
    I've tried to change "<?php get_sidebar(); ?>" to "<?php dynamic_sidebar("sidebar-popular"); ?>" in "template-single.php", but it didn't work. It's surely cause I'm not advanced in coding.. :)

    Thanks in advance for your help!

    Posted 1 year ago #
  2. Elliott
    Support

    Hello Greya,

    Open up /wp-content/themes/infocus/sidebar.php and on line 6 you will see this,

    <?php generated_dynamic_sidebar_webtreats(1) ?>

    What you will want to do is place a check if the page is the category or search page and load your own sidebar like this,

    <?php if (is_category()) { dynamic_sidebar("sidebar-popular"); } else { generated_dynamic_sidebar_webtreats(1); } ?>

    If that does not work then you can also skip through the indexes until it hits your sidebar (you'll have to skip over the footer areas also),

    <?php if (is_search()) { generated_dynamic_sidebar_webtreats(6); } else { generated_dynamic_sidebar_webtreats(1); } ?>

    Let us know if this works for you Greya.

    Posted 1 year ago #
  3. Hello, Elliott.

    The first variant worked - I replaced <?php generated_dynamic_sidebar_webtreats(1) ?> in "sidebar.php" with <?php if (is_category()) { dynamic_sidebar("sidebar-popular"); } else { generated_dynamic_sidebar_webtreats(1); } ?>

    Now my custom sidebar is also shown in all category-pages.

    Thanks a lot for your help and quick reply, again! :)
    Have a nice day!

    Posted 1 year ago #
  4. Elliott
    Support

    Your welcome Greya, let us know if you have any other questions.

    Posted 1 year ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme