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
- Change Posts per page count
- Can I force a metabox to be in one column?
- Post publish only hook?
- Restrict access to post if it is currently being edited
- Query only Posts from Both of Two Category?
- wp_update_term is always launched after wp_insert_term
- why does HTML Tag not working in Post and Page
- Posts are being redirected to xampp home page
- Can I lock a post in position, so it always appears on the homepage?
- Custom post preview without saving
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- How to get a post’s details by shortcode?
- Posts on a Page using functions.php
- Why is my custom template not showing anything?
- $_GET parametters not working in an specific template
- How to get all inline images in post content? [duplicate]
- Link post images to post
- Rewriting blog permalinks
- How to exclude native lazy loading from first image in post content?
- WordPress 5: prevent link from displaying page title instead of URL
- Customizing a new page used for blog posts with Avada theme
- Repeating post how to solve this
- Showing content from WordPress ruins page CSS using WP_Query, without, content does not show
- Show a Category Specific Info Box
- post content includes and seo vs. duplicate content
- Posts don’t appear on the Blog page
- Display the first post’s comments of category in comments.php template
- On the post list, how do you show different text to the main content?
- Showing Unpublished Posts to Logged-out Users?
- Need All the posts with id, title and date [closed]
- List posts related to category on a div [closed]
- How to get only post=’product’