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

I have a widget sidebar, but I'd like dividers between them. I can achieve this in CSS using boring borders, but I have a png image I'd rather use instead.

Is there a way to insert a divider after each widget item? (apart from the last one of course). I can do this in jQuery quite easily but I'd rather do it in the template file if at all possible

I'm guessing it's something for the functions file or where I register the sidebar?

Thank you

share|improve this question
I guess I could add code after: 'after_widget' => '</li>' ? Or is there a better way of doing it? – Phill Oct 20 '12 at 0:43
The solution for excluding the last widget you can find here: wordpress.org/support/topic/… – user22713 Oct 20 '12 at 18:26
up vote 3 down vote accepted
'after_widget' => '',

As far as I know, thats the best way to do it

share|improve this answer

You could use the :after CSS pseudo class, it's widely supported now and it accepts image content.


But I'm afraid that you cannot treat the last widget differently here, or you will have to add a specific class to all the widgets but the last one.

share|improve this answer

You can do it easily by modifying the css of the widget item. You can do more in CSS than the regular borders:

background:url('../img/divider.png') no-repeat center bottom;

No php or unsupported CSS needed.

share|improve this answer

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.