Forums

Count posts and add classes (3 posts)

  1. delikatesy
    Member
    Posted 1 year ago #

    Hi,

    I'm not so good in PHP and need help with the following. In the Loop I am showing 9 posts in a grind. I need to give a special class to all this posts - as counts (not IDs). That means, the 1st post would have the class "post-row-1", 2nd "post-row-2", 3rd "post-row-3" etc.

    I know you can get the loop to count all posts that are on display, but how to write the function, that will add the counts classes to post divs?

    (What is the practival use for it? With CSS I want to show all 9posts as a grid of thumbnails and say make the 3rd and 7th to show title instead of thumbnail)

    thanks

  2. Jarret Cade
    Member
    Posted 1 year ago #

    Have you tried using the post_class() function? http://codex.wordpress.org/Function_Reference/post_class

  3. delikatesy
    Member
    Posted 1 year ago #

    Yes, I know this function. But how to add the counting function into it?

Topic Closed

This topic has been closed to new replies.

About this Topic