In WordPress ecosystem, Widgets are essentials. We usually use average ~10 widgets at any given time. There are few in Sidebar and few in Post contents. By default WordPress doesn’t provide any simple utility by which you could disable specific widget on specific post/page, etc.
Option-1 – Manually
As often you need to disable Sidebar Widget on Specific Post/Page, below simple code snippet will help you to perform the same.
Just add below to functions.php file and you are all set.
1 2 3 4 5 6 |
add_filter( 'sidebars_widgets', 'crunchify_code_disable_widgets' ); function crunchify_code_disable_widgets( $sidebars_widgets ) { if (is_single(array(5,123,43,54))) // replace this with post/page ID $sidebars_widgets = array( false ); return $sidebars_widgets; } |
Option-2 Using Plugin
Display Widget is a WordPress plugin which provides nice functionality using it you could hide or show widgets based on Category, Post or Page.