apply_filters( 'sidebars_widgets', array $sidebars_widgets )

Filters the list of sidebars and their widgets.


Parameters

$sidebars_widgets array
An associative array of sidebars and their widgets.

Top ↑

Source

File: wp-includes/widgets.php. View all references

return apply_filters( 'sidebars_widgets', $sidebars_widgets );


Top ↑

Changelog

Changelog
Version Description
2.7.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Jose Lazo

    Hide Widgets on Specific WordPress Pages

    add_filter( 'sidebars_widgets', 'wpdocs_remove_about_me_widget' );
    function wpdocs_remove_about_me_widget( $sidebars_widgets ) {
        if ( is_admin() ) { 
            return $sidebars_widgets; 
        }
        
        if ( is_page( 'about' ) || is_home() ) {
            $key = array_search( 'text-3', $sidebars_widgets['primary-sidebar'] );
    
            if ( false !== $key ) {
                unset( $sidebars_widgets['primary-sidebar'][ $key ] );
            }
        }
    
        return $sidebars_widgets;
    }

You must log in before being able to contribute a note or feedback.