With the recent release of WordPress 3.0 I’ve been creating some truly unique sites utilising the Thesis Theme in co-ordination with the latest features. Whilst custom post types and taxonomies in Thesis have been well documented elsewhere; one thing that caught me at the last hurdle was the ability to remove sidebars from custom posts whilst leaving them active for standard posts.
After brainstorming different methods and scouring blog and forum posts I finally pieced together a solution that worked. As I didn’t see it mentioned anywhere else, I figured that I would share just in case anyone else finds themselves in a similar situation.
function remove_custom_post_sidebars() {
if( get_post_type() == 'custom_post_name' ) {
?>
<style>
#sidebars { display: none; }
#content { width:100%; }
</style>
<?php
}
add_filter('thesis_hook_before_html', 'remove_custom_post_sidebars');
Simply copy and paste the above into your custom_functions.php file and then edit the bit that says 'custom_post_name'
to whatever your actual custom post type is called. Pretty simple once you know how 😉
Lorene Mascorro says
Excellent content, just what I had been trying to find.
Sudipto says
Hi Daniel,
Thanks for share the code. Can you also share the code for the share bar on the top of the post below the headline.
Thanks in advance
Daniel McClure says
Hey Sudipto!
The code for the social media bar is powered by the custom skin I sell at: http://marketingskins.com
As it is a premium skin I generally don’t just give out huge chunks of the code but as a one off I’m happy to share it for you and have made a direct copy of that specific code within my skin and attached it in an email to you. You may need to edit the CSS slightly to make it work for your site but the bulk is there.
I hope that helps!
Ricky says
Why not just do it with CSS instead of going through the functions.php? Custom post type names are put as a class on the body tag:
.custompost #sidebar{
display: none;
}
.custompost #content{
width: 100%
}