Reputation: 297
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!
Upvotes: 0
Views: 145
Reputation: 14983
Maybe you could use the dynamic_sidebar_params
hook 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:
if(($myGlobalCount % 3) == 0){
//add a custom class
}
Upvotes: 1