My sidebar widget code in functions.php looks like this…
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Home Sidebar',
'id' => 'home-sidebar-widget',
'before_widget' => '<div class="menu side %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="sidebarTitle">',
'after_title' => '</h4>',
));
Which creates this markup on the site…
<div class="menu side widget_text">
<h4>widget 1 title</h4>
<div class="textwidget">Lorem ipsum dolor sit amet</div>
</div>
<div class="menu side widget_text">
<h4>widget 2 title</h4>
<div class="textwidget">Lorem ipsum dolor sit amet</div>
</div>
Here’s what I need (just adding a number to the class collection)…
<div class="menu side s1 widget_text">
<h4>widget 1 title</h4>
<div class="textwidget">Lorem ipsum dolor sit amet</div>
</div>
<div class="menu side s2 widget_text">
<h4>widget 2 title</h4>
<div class="textwidget">Lorem ipsum dolor sit amet</div>
</div>
I would like to add a count variable so that each sidebar gets a number that I can then use for css targeting. How?
There doesn’t seem to be an easy way to do this. However, you can try this rather hackish approach:
You could target specific elements in CSS like so..(won’t work for all browsers of course).
Or use some jQuery to add the classes..
wyrfel’s approach looks like it could work for you though, i’d suggest that over the two above.