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
- Trying to add attribute to my posts’ featured image
- Using foreach loop breaks
- Cannot display or echo alt text on featured image
- Using Advanced Custom Fields to create a per page slider
- Split loop into two columns, how to favor one side over the other
- Can’t get wp_insert_post to work
- Why not yield/iterable in posts interface?
- WordPress Search Results for Multiple Post Types
- Best practice for migration friendly images in posts/pages?
- Changing layout with wp_customise
- Display post category in foreach loop with category link
- How to show part of the_content?
- Dynamic Stylesheet loads but doesn’t finish
- Best way to assign post position in a news site homepage? (no categories, no sticky posts)
- Filter Select results based on selection
- Using loop pagination on single.php
- Why WP_Query(‘showposts=5’) shows only 1 post?
- I would like to have different styles for my posts based on the content of each post
- 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?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Unreadable pagination
- 200 Rewrite blog post links
- How to set a min number of words for a blog post
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- Loop through categories and display posts title under each dropdown
- Get post id in a function when edit/add a post
- how do I get a specific post from a post with a subcategory in WP
- Automatically create child pages and grandchild pages when saving a (parent) page
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Second transition_post_status hook fired instead of the first
- Iterate through posts based on array of categories
- get author_name from queried post
- Displaying Woocommerce Product Category in WordPress
- How to store post ID’s in cookie or session to display the same posts later
- Which hook/action will help me solve my problem?
- Increase offset while looping
- Blog posts repeat
- Post + form + action + results on the same page
- How to add condition in wordpress loop? [closed]
- Open post-content in archive page in a Modal box with bootstrap
- Woocommerce : Can’t get product info in loop
- How to set variable, pass it to a partial file and remove it after?
- how to refresh div on template part?
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Display category name only once inside loop
- Can’t find infinite loop cause
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Post repeating with infinite scroll
- Custom posts in different columns style
- Get children post mime type using parent post_ID wp_post
- Load wordpress content in other domain
- How to show only subcategories in parent category not parent category?
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- two columns of posts on homepage, one of them “favorites”
- Checkbox doesn’t stay checked, conten
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- 404 error when I acess the second page of post-type
- List authors with the last post title and order by last post date
- post thumbnail, conditions, else wont work
- I restricted wordpress by logged users. It’s possible exclude a page?
- Widgets in the loop if active
- List posts that don’t have a specific tag?
- Changing the_posts_navigation() html output
- Which PHP page is the Default Posts Page
- Can we count the WordPress Loop
- Get post id within comments loop
- Syntax error when I try to insert my loop into an unordered list? [closed]
- retrieve post data and insert it in seperate static html page without WordPress
- WP_Query fails despite having 1 post
- WP Insert Post and then go to post