Style Every 2nd Post Differently Using Odd Even Classes

This code enables you to add the same class to every odd number of posts and another class to every even numbered post, on any type of archive.

The code also works in any theme.

You can use the code on your:

  • front page
  • home page
  • blog page
  • taxonomy or term archive
  • or any type of archive page including category, tag, date, author and custom post type archives

The code also enables you to control which pages the classes are added to for paginated archive pages. This means you can use the code to add classes only on the first, second and/or third page etc of any type of archive page.

Here’s the code for logged in members:

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.