My approach. No extra function, no filter. 🙂
<?php $GLOBALS['wpdb']->current_post = 0; ?>
<div <?php post_class( 0 === ++$GLOBALS['wpdb']->current_post % 3 ? 'third' : '' ); ?>>
Alternative:
<div <?php post_class( 0 === ++$GLOBALS['wpdb']->wpse_post_counter % 3 ? 'third' : '' ); ?>>
Related Posts:
- How to mark every 3rd post
- Count posts within a custom post type and specific taxonomy and terms?
- How to Display a List of Users Who Have Made at Least 1 Post?
- How to Display Network Post Count?
- How to cache a shortcode functions output?
- Count posts in category including child categories
- adding a custom css class to post
- Count singular post views automatically
- Set font size automatically according to number of words in post
- Network wide post count (WP Multisite)
- Odd/even class on article tag
- How to add padding between posts
- Redirect based on user post count
- Alternate custom content in the loop
- Show that current post is number X out of X
- Show the author’s count of total amount of posts assign to a custom taxonomy term
- Double count view in archive.php
- Count to how many categories a post belongs to
- Add Post Tags to Body Class
- Count total number across post types
- Count search results in heading
- How to hide first gallery for every post?
- Add a class to post title if a link ends with a certain extension
- Counter of posts ever posted – even deleted ones
- Display Published Posts Count for Certain Time Period
- How to make classes for posts?
- How can I get global $post to work for CPT and update user?
- Display Notification Bar on Header on Certain Post Count
- Show posts count for Categories and Tags in wp_nav_menu
- How to add category post count in main navigation menu [closed]
- Count number of posts of current month
- Add $values to post_class()
- Howto show comment count by post in post?
- Counter is skipping post when I still want it visible [closed]
- Every second post different class in blog view
- Count several post tags
- Get post number both in the loop and in the post
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- Count the number of a post types associated with another post type
- How can I add a class to particular paragraphs in my post?
- Microformats in a single post – layout conflict
- Echo the number of posts being displayed
- wordpress add field to post_class
- Display amount of pending posts in back/front end
- Count user posts and store the number for later use
- why the posts queried from sql is more than those showed on the page?
- Count the total views of all user posts published
- Author post count in category
- Set post title font size automatically according to number of words in post title
- Show post count in custom taxonomy page
- Count singular post views automatically
- How to count posts in tags within time limit
- Display Custom Post Category Count & WordPress Category Count Using Shortcode
- Counting Posts by Category
- Display number of post published every day
- Retrieve posts inside foundation tabs and tab-content split by 3 per row
- Alternative content between posts no repetition
- count_posts to a standalone link
- How to control Post view count incresing in sidebar widget posts too?
- Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)
- How to limit the number of posts a user can publish based on user type
- ho can I get the number of the current post instead of the post id?
- post_count not working
- Adding Count Post in Page
- Count words for all posts by all authors
- Word count for all posts of all authors
- Display post count on archive page in reverse order
- Adding additional data to WP_Post object
- using wp_update_post on save_post
- How do you get all the urls of images attached to a post?
- Get names of authors who have edited a post
- Custom wp_trim_words() function not trimming right
- Automatic value for custom fields for posts
- Display most recent post on homepage?
- get current post id inside hook
- Display all posts that were published before full post on single.php
- How to make number of blog posts a custom field?
- Add Read More Tag to a post content (Single.php)
- How to compare two posts including their meta fields on a scalable base?
- Add a variable in a post
- Is it possible to add a shortcode below post title?
- Image behind the post’s title
- Get the most recently modified post date of most recently modified post
- Get all custom posts with a certain taxonomy
- inserting a category into post
- Limiting the amount of posts retrieved by the loop
- Direct some posts to only appear on a specific page
- How To import post If I have only subscriber access
- Get post publishing date from within custom HTML block
- Updates are not showing to public (New Posts , Theme Change)
- How to bulk Update URLs to new values?
- How can I make a post sub link?
- Display image gallery if more than 1 image
- Change archive results based on GET request
- Let Contributors Review only (Not Publish) Others Posts
- Querying posts from current category, using a variable as array argument
- How to create a Top 10 Popular Posts Page?
- 404 error on every post and page other than home
- Successive creation of over 1000 posts causes 404?
- Do anything on post_status change [duplicate]