Unlimited sidebar for category, taxonomy not showing on posts

Hi there,
I think this issue is related to the topic: https://theme.co/apex/forum/t/sidebar-not-showing-up-on-individual-posts/24436
I am also trying to get custom sidebars to appear on single posts within certain category (or categories)

It worked for one category but no longer works for a new category. See links below:

Hi,

Assigning the category will only show the sidebar on the category page but not on all posts that falls on that category.

You will need to check each posts in Appearance > Sidebars

Thanks

Hi Paul, thanks for your input.
Unfortunately that does not do as expected.
I have tried checking the post title, adding tags, but still the default sidebar appears.

Hi again,

Sidebars that can be assigned from Admin > Appearance > Sidebars are displayable to where it’s assigned. The taxonomy selection will let you only assign a sidebar to specific taxonomy, like example, the category page (/category/music/) will have that sidebar, but not at the post that has music category, please see https://theme.co/apex/forum/t/features-unlimited-sidebars/95

Make sure you update your sidebar after selecting your post under All Pages and Posts. I checked in my local setup and it works as expected. Please clear all caches including your browser’s cache after assigning your sidebar to a post.

If you still have problems kindly get back to us with URL/User/Pass of your WordPress dashboard using the Secure Note functionality of the post to follow up the case.

Thanks!

Hi Nabeel, thanks for looking at this.
A couple of interesting notes:
on one site (PRO installation) the sidebar is working as expected. I can select a single post and make it show a custom sidebar. No taxonomy checked.
on the problem site there are a lot of posts. too many? i cannot scroll to the end of the list. a search field might help here for sites with thousands of posts.
I unchecked all the taxonomies and left a single post checked. but it still shows the default sidebar.

Hi @Mbzo,

You mean do you wish to assign the same custom sidebar to all posts? If yes, then add this code to your child theme’s functions.php

add_filter( 'ups_sidebar', 'ups_display_sidebar_custom', 999999 );

function ups_display_sidebar_custom ( $sidebar ) {

return is_singular('post') ? 'ups-sidebar-test' : $sidebar;

}

This should assign the sidebar with the ID of ups-sidebar-test automatically, forcing the sidebar display.

Thanks!

Thanks Rad, I see what you mean. However, I don´t want to show the custom sidebar on all posts.
Basically I have theree sidebars:

  1. default for most posts
  2. a taxonomy sidebar for a specific set of pages
  3. custom sidebar for individual posts

Hi @Mbzo,

I couldn’t confirm if it’s working or not since there is no sidebar identification within the source code. Perhaps you could provide the correct login credentials? Then I’ll check again and for the meantime, please make sure to disable your Breeze cache.

Thanks!

Hi there Rad,
I disabled breeze and opened the page in a different browser but I can´t get the post specific sidebar to show.
The credentials should work (below)

Hello @Mbzo,

You have added this code:

add_filter( 'ups_sidebar', 'custom_sidebar_on_pages', 9999 );
function custom_sidebar_on_pages ( $default_sidebar ) {
  	if ( in_category( array ('noticias','destaque','publicacoes','video') ) ) {
    	return 'ups-sidebar-projetos';
	} elseif ( in_category('quem-somos') ) {
    	return 'ups-sidebar-institucional';
  	}
	return $default_sidebar;
}

This will only assign custom sidebar to single posts that belongs to a particular category. It does not assign any sidebar to a category archive pages. You may need to update your code and use this instead:

// Category Archive Sidebars and Posts Sidebars
// https://theme.co/apex/forum/t/custom-sidebars-for-category-pages/32936/4
// =============================================================================
add_filter( 'ups_sidebar', 'custom_sidebar_on_pages', 9999 );
function custom_sidebar_on_pages ( $default_sidebar ) {

	// for single posts
  	if ( in_category( array ('noticias','destaque','publicacoes','video') ) ) {
    	return 'ups-sidebar-projetos';
	} elseif ( in_category('quem-somos') ) {
    	return 'ups-sidebar-institucional';
  	}

  	// for category archive pages
  	if ( is_category( array ('noticias','destaque','publicacoes','video') ) ) {
    	return 'ups-sidebar-projetos';
	} elseif ( is_category('quem-somos') ) {
    	return 'ups-sidebar-institucional';
  	}

	return $default_sidebar;
}
// =============================================================================

For your reference, is_category and in_category are two independent conditions.

Hope this helps.

Brilliant. That helps alot. Thanks RueNel.

You’re most welcome!

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