Disable widgets on specific pages by user level

Adding this php code to your functions.php will disable widgets on the home page only, without completely disabling widgets. You could change is_home() to is_page() or specific pages.

add_filter( 'sidebars_widgets', 'disable_all_widgets' );

function disable_all_widgets( $sidebars_widgets ) {
if ( !current_user_can( 'level_5' ) ){
        $sidebars_widgets = array( false );
	return $sidebars_widgets;

Comments  Leave a Reply

  1. Hi, i want to disable a inbuilt category widget. I am using clipper theme, and i dont want the category widget to get displayed on the category page. What would be the code and where do i need to put the code?

  2. Any way to target specific widgets, say turn of all text widgets on page ID x?

    1. hi andy, please I want to target a specific widget on a page with a template… what im tryin to achieve is replicate a widget area under an existing widget such that i can attach a new menu to the new widget area; and then remove the one above it which is curently existing …

  3. This is great when using WP as a CMS, great little snippet love this 🙂

  4. Tweets that mention Wordpress Disable widgets on specific pages – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com November 22, 2010 at 10:01 am

    […] This post was mentioned on Twitter by Hash WordPress, Patricia Skinner. Patricia Skinner said: RT @hashwordpress: RT @wpsnipp #wordpress Disable widgets on specific pages http://bit.ly/cPS1eV #blog please RT 🙂 […]

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!