Different sidebars on different category pages

Hello, I need to add different sidebars on different category pages. How can I achieve that?

Hey Olivier,

You can use the Unlimited Sidebars feature for this. For usage instructions, please see https://theme.co/apex/forum/t/features-unlimited-sidebars/95

Just add a sidebar and assign your category under All Taxonomies.

Hope that helps.

Hey thanks for the support that worked perfectly. However, I still have issues with how to add a custom sidebar on some custom post types. Right now, I am using the “modern event calendar” and cant find out how to put a sidebar on the categories or events pages, please help.

Hi There,

The event pages already have the sidebar, you can add the widget the single event page sidebar under Appearance > Widgets > MEC Single Sidebar:

To add the sidebar for the event categories, you need to setup a child theme first:

After that add this custom code under functions.php file locates in your child theme:

function x_get_content_layout() {

    $content_layout = x_get_option( 'x_layout_content' );

    if ( $content_layout != 'full-width' ) {
      if ( is_home() ) {
        $opt    = x_get_option( 'x_blog_layout' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_singular( 'post' ) ) {
        $meta   = get_post_meta( get_the_ID(), '_x_post_layout', true );
        $layout = ( $meta == 'on' ) ? 'full-width' : $content_layout;
      } elseif ( x_is_portfolio_item() ) {
        $layout = 'full-width';
      } elseif ( x_is_portfolio() ) {
        $meta   = get_post_meta( get_the_ID(), '_x_portfolio_layout', true );
        $layout = ( $meta == 'sidebar' ) ? $content_layout : $meta;
      } elseif ( is_page_template( 'template-layout-content-sidebar.php' ) ) {
        $layout = 'content-sidebar';
      } elseif ( is_page_template( 'template-layout-sidebar-content.php' ) ) {
        $layout = 'sidebar-content';
      } elseif ( is_page_template( 'template-layout-full-width.php' ) ) {
        $layout = 'full-width';
      } elseif ( is_archive() ) {
        if ( x_is_shop() || x_is_product_category() || x_is_product_tag() ) {
          $opt    = x_get_option( 'x_woocommerce_shop_layout_content' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        } else {
          $opt    = x_get_option( 'x_archive_layout' );
          $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
        }
      } elseif ( x_is_product() ) {
        $layout = 'full-width';
      } elseif ( x_is_bbpress() ) {
        $opt    = x_get_option( 'x_bbpress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( x_is_buddypress() ) {
        $opt    = x_get_option( 'x_buddypress_layout_content' );
        $layout = ( $opt == 'sidebar' ) ? $content_layout : $opt;
      } elseif ( is_404() ) {
        $layout = 'full-width';
      } else {
        $layout = $content_layout;
      }

      if(is_tax( 'mec_category' )){
        $layout = 'content-sidebar';
      }
    } else {
      $layout = $content_layout;
    }

    return $layout;

}

add_filter( 'ups_sidebar', 'x_event_category_sidebar' );
function x_event_category_sidebar($sidebar){
  if( is_tax('mec_category') ){
    return 'ups-sidebar-event-category';
  }
  return $sidebar;
}

The ups-sidebar-event-category text is your sidebar ID.

Hope it helps :slight_smile:

Thank you for the support. Before seeking your support, I have seen that sidebar (MEC Single Sidebar) but it doesnt work at all. see the picture below

It simply shows nothing. About the code you shared, I applied it in the child theme but nothing works. There is no change at all.

i think you might need my credentials to help me:

Please support me.

Hey Olivier,

It is not possible to assign a sidebar to Modern Events Calendar pages because it has it’s own content template. MEC displays aren’t designed to have a sidebar. It’s only because of the unique sidebar display of the Icon stack that the sidebar showed up. But, it wasn’t meant to be and it couldn’t be filled with content without drastic custom development.

I’ve made MEC’s single and archive pages Fullwidth to eliminate the blank space.

As for MEC’s archive page, I inserted this condition under is_archive

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.