• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Add Class To 1st Post On First Page of Paginated Archive Page

This PHP code enables you to add a custom class to the first post on any archive page loop.

The code, which works in any theme, only adds your custom class to the 1st post on the 1st page only so.

Video Demo

This means that the 2nd and subsequent pages of your paginated archive will remain uneffected andthe classonly added to one post in the entire loop.

You can use the code in:

  1. A template file, using the WordPress Template Hierachy
  2. Your functions file with conditional tag

On top of this, you can use replicate the code to add custom classes to 2nd, 3rd and other posts in any archive loop.

Here’s the code for logged in members:

Register for full access

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags