WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I get the number (count) of, let's say, text widgets from a sidebar?

for eg. if I drop 4 text widgets in the sidebar, I want to get this number somehow from another widget

share|improve this question
up vote 1 down vote accepted

Call wp_get_sidebars_widgets(), and loop through each sidebar. Off the top of my head, text widgets have an ID like widget_text-$i.

share|improve this answer
All widgets have a numeric value on the end don't they, to indicate what instance of the widget it is(assuming a given widget supports multiple instances). Looks like the sidebar array stores widget names minus the widget_ prefix though, so text widgets have a name like text-1, text-2 and so on.. – t31os Dec 12 '10 at 11:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.