@Milo’s answer worked perfectly (see comment above).
if (in_array($post->ID, $do_not_duplicate)) continue;
meant that duplicate posts were still being counted in the loop, though not being displayed.
To fix, remove this line, and exclude duplicate posts from the query with this argument:
'post__not_in' => $do_not_duplicate
.
Thank you @Milo for your swift and succinct response.
Related Posts:
- Is it necessary to reset the query after using get_posts()?
- ACF Repeater loops and resets – where is the reset_rows() documentation? [closed]
- Post Loop not Returning Permalink
- Get posts that matches specific terms of multiple custom taxonomies
- Is get_posts() more efficient than The Loop?
- How to get_posts where ‘menu_order’ is more than 0/zero?
- Display the_content on click jquery
- What is the maximum number of posts a WordPress loop can work with?
- Why only one post (and no pagination) on this variation of the loop?
- Sort posts by most recently modified
- A smarter way to display multiple loops inside a page template
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- Show all posts using the template page and the loop?
- Showing sticky posts with get_posts()
- query_posts() vs get_posts() multiple loops [duplicate]
- How do I paginate a get_posts() request inside another page loop (Paginating childpages)
- Both a page loop and posts loop on the same page
- How to get The Loop working with $wpdb->get_results()
- Multiple get_posts() queries on one page
- 404 Template customization | Want 10 recent Post on the 404.php error page apart from the error Notice
- Output meta into arrays
- Get post offset/posts page offset in single post page (outside the loop)
- get_posts() forcing ignore sticky posts on main loop
- loop inside a loop : search for posts in the same category
- php loop error for count posts in category
- get_posts and wp_autop (remove filter)
- Need some help with “the_widget()” function
- Is there a way to target only images within the loop?
- Show last post from multiple categories using wp_list_categories
- Question about custom plugin
- Retrieve each widget separately from a sidebar
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Adding ‘current_post_item’ class to current post in the loop
- Where should I use post_class()?
- Landing Page – Redirect Loop?
- Loop through two different sets of custom fields
- Sort Popular Posts by Views for the Last Week
- get_the_foo() in the loop – does it perform another query?
- Is it possible to display previous post revision?
- Check if date of post is yesterday
- Fix inefficient loop breaks post.php on form submit
- Adding Pagination on a Custom Author Page
- Adding shortcode closing tag after a loop
- Get Pagination (WP-PageNavi) not to work
- Filtering The Loop For Single Page and Blog Page
- the_content() seems to block my ACF-code
- Pulling current post/page data into header.php
- Removing the_content() from the page
- Loop and Page template : my WP_query don’t take args
- Filter the loop by categories using checkbox form
- Get single post from tags array
- Duplicated posts on category page
- WordPress loop: exclude if it is the latest post
- Apply an Incremental Counter in an Array Function
- Page-loop is looping content from custom loops on the same site. How to avoid that?
- WordPress: Loop Help
- Woocommerce: How to display product price [closed]
- Display Post Author Link above the loop
- Enabling users to control custom loop’s query
- Loop counter style
- Can I add generic numbering HTML classes to items as a loop runs?
- Custom Post Type on Homepage – Studiopress Genesis Framework
- New loop vs widget
- display post format text in loop
- Yoast taking over my WordPress title tag [closed]
- Pagination broken after using 2 loops to show content
- Getting page slug
- Exclude page from loop results
- How is WordPress changing the content markup?
- Use BuddyPress data in loop (mkdir)
- Wrap every four posts within a div [duplicate]
- Get most recent post for every term in a given taxonomy type
- How to access $wp_query object from array of posts given by get_posts?
- Custom Blog Loop on Home Page
- Add File Attachment Name and URL into Javascript
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Open Graph in Index Loop
- How to get post category and author name for cusmot API?
- How to add Default Level-0 parent and Level-1 class in WordPress Category in li element?
- Updating Post meta (ACF field) from Feed
- How to add pagination in Terms
- A code that I could not fully grasp related to foreach & count_user_posts()
- Related posts queries
- Include only one category but Exclude if is in a category from loop
- Homepage Loop Somehow Breaks Styling Of Post Grid
- WordPress Pages in an Array
- Archive sorted by month – separate
- Display single post inside accordion based on form submission results
- One page loop issue with posts
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Can’t print out returned value
- Building theme so user can change header image [closed]
- Get query result before posts are displayed?
- WordPress Group By Problem
- Home page loop with pagination problem
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- I want the first post on my home page to be lengthier than the rest (example included)
- How can you make it so the comment box shows on some pages or posts but not all?