Site logo

Archived topic

Custom Sidebar Layout Filter Not Working

10 replies · Started by Paul on September 1, 2017

Viewing posts 1–11 of 11

Hi Tom and Leo;

I tried using a sidebar filter in my child theme's functions.php file to remove all sidebars from posts with the category slug 'student-articles' but it's not working; the globally set right sidebar still shows on all these category posts. I flushed the cache too.

Here's my code:

add_filter( 'generate_sidebar_layout','tu_custom_category_sidebar_layout' );
function tu_custom_category_sidebar_layout( $layout )
{
 	// If we are on a category, set the sidebar
 	if ( is_category( 'student-articles' ) )
 	 	return 'no-sidebar';

 	// Or else, set the regular layout
 	return $layout;

 }

Any ideas? Maybe it's not compatible with the current GP release? I note the article at https://docs.generatepress.com/article/sidebar-layout/ was last updated on December 24, 2016.

Hi there,

That should still work as nothing has changed there.

Can you link me to a page that's not working?

Thanks!

Hi Paul and Leo

I think what needs to be checked here is if is_singular && in_category

You got it Jamal! Thanks so much.

Weird thing happened since I posted this request yesterday. Now my custom page headers aren't working at all. I removed the above function from my functions file and still no custom page headers.

Hmm the function shouldn't have anything to do with page headers.

Can you link us to the page?

Update: I can set a GLOBAL page header to all posts successfully, but when I assign a different custom page header style to a specific category of posts, the global page header style is displayed on those category's single posts instead. Can't seem to override the global one by category.

Leo,

Click on any post in http://dev.ayurvedacollege.com/articles/ -- these are all set to a Global page header (General Articles page header) with a Green background.

Compare to the 'student-articles' category posts at: http://dev.ayurvedacollege.com/student-papers/ -- this category uses a custom page header (Student Articles page header) with a Blue background. As you can see, the Global Green page header is being rendered instead even though that category has been set to the Student Articles page header.

Click on any one of the posts listed on that page to see the problem, Leo. Each one of those posts should have a Blue header with white H1 title in it.

General articles (accessed via /articles) should have a Green header with title instead.

This archived topic is closed to new replies.