Skip to content

Instantly share code, notes, and snippets.

@oxocode
Last active December 24, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oxocode/6820505 to your computer and use it in GitHub Desktop.
Save oxocode/6820505 to your computer and use it in GitHub Desktop.
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