You are adding post IDs to $do_not_duplicate
, but you are missing the other half of the process- excluding those post IDs from subsequent queries. You can do that by setting post__not_in
with the array of IDs you don’t want returned.
$args = array(
'posts_per_page' => 1,
'paged' => $page,
'cat' => 2,
'post__not_in' => $do_not_duplicate,
);
Related Posts:
- Inject post (from specific category) between posts in Loop
- Wp Query : Order by distance lat,lon
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- Query multiple custom post types in single loop
- Build a content and excerpt grid loop with paging and options for # of posts
- retrieve thumbnail from post ID of best selling product in category
- Looking to exclude blog posts from category Previous/Next buttons
- Alter secondary loop to exclude posts from current page category
- How to display related posts from parent category
- User Defined order on get_categories?
- Search widget breaks when using multiple loops?
- Use template for posts with a particular category grandparent
- Count number of published posts by type
- Custom Loop through category menu to include sub categories
- How to exclude specific category from the get_the_category(); array
- Get taxonomy terms only of the WP_Query current posts
- How to get to a specific position in wp_query?
- Get category name from custom loop and echo it once
- Hide post if matches current month and year
- have_posts() execution failure
- How can I use wp_query to show all product data using just the products ID?
- Using foreach loop breaks
- Display post category in foreach loop with category link
- Filter Select results based on selection
- Why WP_Query(‘showposts=5’) shows only 1 post?
- how do I get a specific post from a post with a subcategory in WP
- How to store post ID’s in cookie or session to display the same posts later
- How can I add extra word in permalink when someone click download button?
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Alert Bar section within WP loop is displaying even though there are no posts
- remove post that has no content
- Display category name only once inside loop
- 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
- List authors with the last post title and order by last post date
- Redirect to another page using contact form 7? [closed]
- WP_Query fails despite having 1 post
- wp_query get the 2nd post
- How to get post ID in a Page?
- the_post(); prints out style text into my HTML?
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- Pagination at category doesnt work with same name of page
- How to show categories and date on posts
- Display articles with a different template in the home page | Solved |
- in_array not working on dev server but works on localhost
- WordPress sorting posts by date and title using a dropdown
- posts_per_page displays only 2 posts instead of 4 posts
- Is there anyway I can call the year once?
- Query on a repeater date (acf)
- Trying to show the category of a post in the post display
- Need to show 7 posts from actual date
- Check the database for a postmeta field
- Getting info about selected posts using one WP_Query
- How to display sticky post always at the top (before regular post) in wordpress?
- Return to the beginning of the results of a for loop
- Exclude category and post from loop in custom category.php
- How to display last whole post on the homepage
- How do if all posts has this category ID then do this
- Custom Post By Category
- Making list of posts with chosen description
- Get current_post in reverse order with pagination
- Displaying 3 Category Posts differently
- Add div after every 4 posts then every 2 posts for a responsive loop
- My query keeps looping infinitely ! how to stop it?
- Efficient way of querying for a “fallback” post?
- Insert div after every three posts in home.php [duplicate]
- Only show current category post
- Unable to get Post Category Name and URL
- For each 3 posts, show a different post type
- Add post class in custom loop (WP_QUERY)
- Only Get A Certain Number of Posts From WP_Query
- Create a hierarchical loop at predefined markup requirements
- insert thumbnail image from php script
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Automatically create a loop for post ID
- Query category-specific, paginated posts and allow viewer to change sort order
- Query seems to be duplicated
- Why does WP_Query show only the same post even with different categories and endwhile?
- Trying to see if page is category or single and displaying title with appropriate heading tag
- Make assigning post to a specific category equivalent to assigning it to all categories
- Error trying import one category on page
- Advanced Taxonomy query, with 3 post types
- Remove the_content From Loop
- Why does a meta_query break this WP_Query?
- WordPress post pagination on custom template not working
- Pagination in category.php not functioning
- Display post of specific category on page
- How to modify this function to exclude also the post belonging to a specific category?
- Fix incorrect related posts code snippet
- Excerpt all post content Content Same Size without word cutting off
- How to create a loop that will display one post and stop?
- Display all categories (with link) of custom post type – WordPress
- Count the number of matching post names in foreach loop
- How do I exclude the current post from the upcoming post query
- How do I display WooCommerce products in my query to rows of 3?
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress
- How to show correct td of table tags in wp_query loop
- How to make posts_like_dislike reference current post when iterating?
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?