wordpress snippets last updated   : September 29, 2014
we now have 639 snippets

Disable sidebar widgets on specific posts

wordpress snippet

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.

snippet :  PHPcopy
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;
}

Did you like this post? If so please share it with your friends. Thanks!

  • http://sumtips.com Leo

    This disables the whole sidebar on a specific post?

    • http://wpsnipp.com Kevin Chard

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