Codex

Function Reference/is active widget

Contents

Description

This Conditional Tag checks whether widget is displayied on the front-end. This is a boolean function, meaning it returns either TRUE or FALSE.

Usage

 <?php is_active_widget$callback$widget_id$id_base$skip_inactive ); ?> 

Parameters

$callback
(boolean) (optional) Widget callback to check.
Default: False
$widget_id
(int) (optional) Widget ID.
Default: None
$id_base
(string) (optional) Widget ID.
Default: None
$skip_inactive
(boolean) (optional) Widget ID.
Default: True

Return Values

(mixed) 
Returns false if the specified widget is not active, or the id of the sidebar in which the widget is active. If the callback is non-unique you can optionally specify the ID of the widget.

Examples

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


<?php
if ( is_active_widget() ) {
    
// ...
} else {
    
// ...
};
?>

Change Log

Since: 2.2.0

Source File

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

Related

Widgets API: is_active_sidebar, register_sidebars, register_sidebar, unregister_sidebar, is_dynamic_sidebar, dynamic_sidebar, register_sidebar_widget, unregister_sidebar_widget, wp_register_sidebar_widget, wp_unregister_sidebar_widget, wp_get_sidebars_widgets, wp_set_sidebars_widgets, is_active_widget, the_widget, register_widget, unregister_widget, register_widget_control, unregister_widget_control, wp_register_widget_control, wp_unregister_widget_control, wp_convert_widget_settings, wp_get_widget_defaults, wp_widget_description

is_home(), is_front_page(), is_search(), is_404(), is_singular(), is_page(), is_attachment(), is_local_attachment(), is_single(), is_sticky(), is_archive(), is_category(), is_tag(), is_author(), is_date(), is_year(), is_month(), is_day(), is_time(), is_admin(), is_preview(), is_paged(), is_page_template(), is plugin active(), is_plugin_page(), is_new_day(), is_feed(), is_trackback(), is_comments_popup(), comments_open(), pings_open(), is_taxonomy(), is_taxonomy_hierarchical(), is_term(), is_user_logged_in(), is_blog_installed(), is_active_sidebar(), is_dynamic_sidebar(), is_active_widget(), in_the_loop(), in_category(), has_tag(), has_excerpt()