The WP_Query object has a property called current_post
to indicates which post the loop is currently processing. So you can write a similar condition inside your loop:
global $wp_query;
while (have_posts()) {
the_post();
if ($wp_query->current_post % 3 === 0) {
// your code
}
// Your article
}
Related Posts:
- Inject post (from specific category) between posts in Loop
- Displaying the last post on static homepage
- How can I add extra word in permalink when someone click download button?
- remove post that has no content
- How to avoid duplicates when creating recent network posts
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- WordPress query undefined offset in loop
- Only show first image in foreach loop
- Do not duplicate posts with multiple categories in multiple loops
- show recent posts php code error?
- How to pick “full/thumbnail” images in the loop?
- Wp Query : Order by distance lat,lon
- Display articles with a different template in the home page | Solved |
- Is there anyway I can call the year once?
- Having trouble with customizing blog posts on the home page
- How do if all posts has this category ID then do this
- Get current_post in reverse order with pagination
- Add div after every 4 posts then every 2 posts for a responsive loop
- Automatically create a loop for post ID
- Adding if statement to content for homepage
- Excerpt all post content Content Same Size without word cutting off
- How to create a loop that will display one post and stop?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Count the number of matching post names in foreach loop
- Guidance with The Loop for CMS
- How to add active class to custom menu using while loop and wp_list_pages
- Print html when custom field has value inside while loop
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- post expire after x days
- Go to / Scroll to Password Field on WordPress Posts After Submit With Message(s)
- New Plugin Review
- Use template for posts with a particular category grandparent
- How do I display the function the_content in this loop?
- How to get to a specific position in wp_query?
- Facebook “like” open graph meta in header.php
- “before delete post” action fire when the post is updated?
- Automatically add custom CSS to new posts using a category template
- Query all posts of a custom taxonomy term
- Using foreach loop breaks
- Loop with slider (slider not loading)
- How to hide all child pages with post_query?
- How to sort posts based on the value (number) of a post’s metadata?
- Automatically create child pages and grandchild pages when saving a (parent) page
- Displaying Woocommerce Product Category in WordPress
- Woocommerce : Can’t get product info in loop
- Let Users Choose Post Categories
- Custom posts in different columns style
- 404 error when I acess the second page of post-type
- Which PHP page is the Default Posts Page
- Can we count the WordPress Loop
- Add content after the first post in WP Loop
- Copy taxonomy terms from one post to another programmatically
- How to include custom code on a page that’s set to act as homepage?
- Last class on last headline?
- How to catch wordpress post ID when it’s published
- WordPress upload file size error even after raising php limits
- Displaying list of posts in category page
- Echoing a CSS class based on category of post in a list
- Php code error in wordpress if else statements [closed]
- pagination broken – clicking next displays “page not found”
- Search.php gets metadata from first post
- remove specificly the last tag in all posts
- Pagination at category doesnt work with same name of page
- Add posts to custom table in database instead of wp_posts
- How to show categories and date on posts
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- Check if current post in loop is last on current page
- Query on a repeater date (acf)
- Trying to show the category of a post in the post display
- Split post or page content in two or more columns
- Check the database for a postmeta field
- Send POST request to Flask app from functions.php file
- Send Notification after post published was working but stopped after the last WP update
- adding or removing endforeach; throws error!
- Adding PHP to an if else loop
- How to insert text into post based on category – via single.php file
- Generate random access token to a post page
- Filter loop by ‘price’ with meta_query
- Problems with the WordPress loop [closed]
- Only display notification on single post
- Loop returns more items than exist?
- ‘posts_per_page’ in costum page type
- Modify category archive page loop on functions.php
- WP_Post is not from correct array
- Post formating on Home page
- divide custom field values in div every two values
- List of child pages fetch next results at link click
- How to display html code on homepage
- Limit ads appearing more than three times
- Auto create description in post
- Pagination on Custom Loop
- Advanced Taxonomy query, with 3 post types
- Custom single.php files for different post formats
- Troubleshooting “loopback requests that take too long”
- How to modify this function to exclude also the post belonging to a specific category?
- How to list all the posts in a personalized page? WordPress
- Help with if/else loop [closed]
- Set post to draft if matching word is found in the post
- How to create a WordPress PAGE in another folder?
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress