is_active_sidebar() – Determines whether a sidebar is in use.
You appear to be a bot. Output may be restricted
Description
Determines whether a sidebar contains widgets.
For more information on this and similar theme functions, check out the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ Conditional Tags} article in the Theme Developer Handbook.
Usage
$bool = is_active_sidebar( $index );
Parameters
- $index
- ( string|int ) required – Sidebar name, id or number to check.
Returns
bool True if the sidebar has widgets, false otherwise.
Source
File name: wordpress/wp-includes/widgets.php
Lines:
1 to 16 of 16
function is_active_sidebar( $index ) { $index = ( is_int( $index ) ) ? "sidebar-$index" : sanitize_title( $index ); $sidebars_widgets = wp_get_sidebars_widgets(); $is_active_sidebar = ! empty( $sidebars_widgets[ $index ] ); /** * Filters whether a dynamic sidebar is considered "active". * * @since 3.9.0 * * @param bool $is_active_sidebar Whether or not the sidebar should be considered "active". * In other words, whether the sidebar contains any widgets. * @param int|string $index Index, name, or ID of the dynamic sidebar. */ return apply_filters( 'is_active_sidebar', $is_active_sidebar, $index ); }