How to filter out sidebars on specific category posts, and some specific pages
-
I’m diving into the world of hooks and filters and need a little advice.
I want to have the sidebars removed and the content area widened to the full page when product-specific categories used in a single post display. I’ve read up using filters for this, found an example and am modifying it for my use.
Here is my function code:
function product_posts_no_sidebar() { global $post; if ( !is_category() ) return; $cats=get_the_category($post->ID); foreach($cats as $cat) { if( in_array($cat->cat_name,array("store-all")) ) { {?> <style> #secondary { display: none; border: none; } .site-content {width:100%; background} </style> <?php } } } } add_filter('THIS IS MY PROBLEM AREA', 'product_posts_no_sidebar');
As you can see, I do not know what filter to put in the first part of the add_filter spot. I have read the long list of the Plugin API/Filter Reference on the Codex and I’m not able to determine what filter I would need to reference. Would it be a content reference? I’m not grasping which one would apply.
What filter would be the appropriate one to place here?
And then, I have some pages where I want to accomplish the same result (no sidebar and full width content), but this would be by applying it to all my store-specific page templates and not the default page template. So, “all page templates except page.php”.
Would appreciate some advice. Thanks!
- The topic ‘How to filter out sidebars on specific category posts, and some specific pages’ is closed to new replies.