I want to add different class (css) in widgets in site sidebar .
For example:
First widget in Sidebar -> class=sidebar-top1
Second widget in Sidebar -> class=sidebar-top2
third widget in Sidebar -> class=sidebar-top3
i want to add class in <div> tag.
how i can to do?
Check out this post I wrote on the wordpress.org board… it has some functioning code you can work from: http://wordpress.org/support/topic/how-to-first-and-last-css-classes-for-sidebar-widgets
What a coincidence, I just spent several hours messing with widget classes. I won’t post my resulting code because it does stuff that is more complex and out of context for your question. Here are basics (or maybe “basics”):
dynamic_sidebar_params
hook.$params[0]
.$params[0]['name']
.$params[0]['before_widget']
.So you can filter this hook, check for sidebar you want to modify, keep track of widget count (likely with
static
variable), modify wrapper and return modified widget parameters.I am way to sleepy to write out specific code, leave a comment if you still need help with this and I will get back to it tomorrow.