Archived topic
How To Disable Sidebar Per Category
5 replies · Started by Sharif on May 13, 2017
Hi,
Is there any solution how to disable sidebars per category?
Regards,
Hi there,
This might help: https://docs.generatepress.com/article/sidebar-layout/#using-a-function
How to use category conditional tag: https://codex.wordpress.org/Conditional_Tags#A_Category_Page
Let me know if you need more info.
Thanks Leo,
Cool. Solved my problem.
Here comes another question in my mind.
Is there any snippet if I disable sidebar per category it will be disabled authomatically in all posts of that category so I should not go post per post to disable sidebar?
Regards,
I think you have to write a similar function using a different tag:
https://codex.wordpress.org/Conditional_Tags#A_Single_Page.2C_a_Single_Post.2C_an_Attachment_or_Any_Other_Custom_Post_Type
Hi,
I want to disable sidebar in more than one category using snippet provided in this URL:
https://docs.generatepress.com/article/sidebar-layout/#using-a-function
I see that sidebar is disabled in one category but not in all of them.
I also added three sniipets for three categories seperately but code snippet plugin did not accept more than one.
I have three categories and slugs are math, physics and chemistry and changed if ( is_category() ) to if ( is_category('math','physics','chemistry') ) but it did not work for all of them.
Regards,
You could do this:
if ( is_category( array( 'test', 'example', 20, 'one-more' ) ) ) {
return false;
}