Is there a way to count widgets in widgetized area in WordPress.
I need to add specific class for every 3rd widget.
For example:
<div class="widget-item">...</div>
<div class="widget-item">...</div>
<div class="widget-item foo">...</div>
<div class="widget-item">...</div>
<div class="widget-item">...</div>
<div class="widget-item foo">...</div>
and so on…
Thanks!
Maybe you could use the
dynamic_sidebar_paramshook for that.Here’s a tutorial for something not so different:
http://wpshock.com/add-first-last-css-class-automatically-to-wordpress-widgets/
In the described solution, you keep a global variable for counting the currents sidebar widgets.
So something like this should enable you to add a class to every 3rd widget: