X

Disable sidebar widgets on specific posts

Adding this snippet to the functions.php of your wordpress theme will let you disable widgets on specific posts by updating the array on line 3 with post ID's. Please note that this is a comma separated list of ID's.



Code Snippet:


add_filter( 'sidebars_widgets', 'disable_sidebar_widgets' );
function disable_sidebar_widgets( $sidebars_widgets ) {
if (is_single(array(1,2,4,8)))
$sidebars_widgets = array( false );
return $sidebars_widgets;
}

Comments  Leave a Reply

  1. Thanks. This is the fourth or fifth thing I’ve tried and the only one that’s worked.

  2. This disables the whole sidebar on a specific post?

    1. This does not disable the side bar but stops all widgets from loading. The sidebar html code will still be displayed.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!