Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Count Sidebar Widgets.Need to get the number of widgets for a specific sidebar? Use this function by passing in the ‘id’ of the sidebar.
<?php
function get_widgets_count( $sidebar_id ){
$sidebars_widgets = wp_get_sidebars_widgets();
return (int) count( (array) $sidebars_widgets[ $sidebar_id ] );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.