Skip to content

Instantly share code, notes, and snippets.

@pankamilr
Created June 1, 2015 11:06
Show Gist options
  • Save pankamilr/20ba1791fe7dac4c6291 to your computer and use it in GitHub Desktop.
Save pankamilr/20ba1791fe7dac4c6291 to your computer and use it in GitHub Desktop.
Check if Wordpress sidebar widget area is empty or not
function count_widgets_in_area($area) {
$widgets = get_option('sidebars_widgets');
if(isset($widgets[$area])) {
return count($widgets[$area]);
}
return null;
}
if(!is_null(count_widgets_in_area("area_id"))) {
// there are some widgets
} else {
// widget area is empty
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment