WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is active sidebar

Description

This Conditional Tag checks if a given sidebar is active (in use). This is a boolean function, meaning it returns either TRUE or FALSE.

Any sidebar that contains widgets will return TRUE, whereas any sidebar that does not contain any widgets will return FALSE.

Usage

 <?php is_active_sidebar$index ); ?> 

Parameters

$index
(mixed) (required) Sidebar name or id.
Default: None

Return Values

(boolean) 
True if the sidebar is in use, otherwise the function returns false

Examples

Display different output depending on whether the sidebar is active or not.

<?php if ( is_active_sidebar( 'left-sidebar' ) ) { ?>
	<ul id="sidebar">
		<?php dynamic_sidebar( 'left-sidebar' ); ?>
	</ul>
<?php } ?>

in the "Twenty Ten" theme (3.0+)

Change Log

Since: 2.8.0

Source File

is_active_sidebar() is located in wp-includes/widgets.php.

Related

Sidebars: is_active_sidebar(), is_dynamic_sidebar(), dynamic_sidebar(), register_sidebars(), register_sidebar(), unregister_sidebar(), wp_register_sidebar_widget(), wp_unregister_sidebar_widget(), wp_get_sidebars_widgets(), wp_set_sidebars_widgets()

See also index of Function Reference and index of Template Tags.