I used is_sidebar_active('NameOfSidebar'), but it seems not working. It returns false all the time. I wanna have a condition that goes like this

if('sidebar is not active'){
 //must not display the section title.
 //display the sidebar here..
  • 1
    Are there any widgets in that particular sidebar area? If not, then it will return false. Aug 5, 2014 at 11:20
  • Yes, there is. I used post meta video widget. Though I didn't add video for certain page, the video section is still showing. I'll try is_active_sidebar and see if it works
    – HML
    Aug 6, 2014 at 3:11
  • Per the answers below you seem to have mis-typed the function name. is_sidebar_active() does not exist. I am surprised that you didn't get an error. Aug 6, 2014 at 11:47
  • I just mistyped it here, I used is_active_sidebar on my code. sorry for that.
    – HML
    Aug 8, 2014 at 4:54
  • Then maybe you have the ID wrong? That is the correct function for what you are trying to do. Aug 8, 2014 at 9:53

3 Answers 3


Try is_active_sidebar

if ( is_active_sidebar('your-sidebar-i.d'))

Where your-sidebar-i.d equals the I.D you use when you register the sidebar.


You want to use a not (!) in your conditional.

if (!is_active_sidebar('NameOfSidebar')){
    // Must not display the section title.
} else {
    // Display the sidebar here.

The first condition will return true if is_active_sidebar() returns false. is_active_sidebar() returns false if that sidebar has no active widgets saved to it.

  • This is accurate, no idea why people are down-voting this... Jan 10, 2023 at 9:57

This snippet checks all widgets in an area e.g. sidebar:

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

Source: https://gist.github.com/pankamilr/20ba1791fe7dac4c6291

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.