Custom sidebar for each post type in Sage

Hello,

I was just wondering how I could make Sage displal a custom sidebar template for each post type that there is on my site.

Normally, in ‘vanilla’ :slight_smile: Wordpress, I could use a conditional like so:

<?php if(is_blog()) get_sidebar('custom'); else get_sidebar();?>

In Sage, however, the displaying of the sidebar is controlled by ConditionalTagCheck class.

How should I go about displaying differnt sidebars per post type?

Would the solution be to filter the Sage wrapper as per ‘Filtering the Wrapper’ ?

Hi luqo33,
you can use a conditional statement right in /templates/sidebar.php

Example:

 <?php 
if (is_blog()) {
  dynamic_sidebar('sidebar-blog');
} else {
  dynamic_sidebar('sidebar-primary');
}
?>

or use a plugin like:

I belive that depends how many different sidebars you need to manage.

1 Like