Support » How-To and Troubleshooting » odd/even style to widget lists

odd/even style to widget lists

  • neologan


    I’d like to achieve adding a class to each li elements from within a widget, like this:

    <div id="categories-3" class="widget widget_categories"><h3>Categories</h3>
       <li class="cat-item cat-item-13 odd">list element 1</li>
       <li class="cat-item cat-item-13 even">list element 2</li>
       <li class="cat-item cat-item-13 odd">list element 3</li>
       <li class="cat-item cat-item-13 even">list element 4</li>

    Odd / even being what i want to do.

    Does anyone know how this can be done?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Not sure if you can do that within a widget. It could be done easily adding a few lines of jQuery (javascript) code to the theme header. Is that approach acceptable to you? If so I’ll show you the code.



    i would certainly like to know the jquery way if it’s not too resource hungry.

    But there must be a way. If the li elements already have a class, which they do, surely there must be a filter that can be used for this, a bit like how this was achieved(?):


    Anyhow, would love to know the jquery method just so it solves the problems for now.



    found the jQuery code myself. Thanks for the heads up, it does the job nicely.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘odd/even style to widget lists’ is closed to new replies.