Just a note before: the question refers to both my answers and editing / adding onto people's answers.

Lately, I've been trying to be more active on the WordPress StackExchange by contributing, as the community has helped me tremendously. Given my experience is not as great as of yet, I'm stuck to menial tasks at best.

But sometimes I stumble over this tiny thing that kills your theme's blog posts.

The horror of the duplicate posts.

Here's an example of a good answer that lacks the patch:

Displaying the first, second, and third posts from a category in separate slides

Great answer. Except if you had multiple "layout widgets", say, a slider, on your homepage, you'd see duplicate posts.

Is this bad? Very. From an SEO perspective, common-sense and UX.

The fix? I can't vouch for whether this is a great way to do it or not, but it works, adding a global and storing each post you've looped through before to that list, simply to avoid using that same post in your next widgets:

global $duplicated_posts;
$query = new \WP_Query( $args );
if ( $query->have_posts() ) : ?>
while ( $query->have_posts() ) : $query->the_post();
$duplicated_posts[] = get_the_ID(); 

And then finally using it in your WP_Query:

$args = array(
    'post_type'                 => 'post',
    'posts_per_page'            => 2,
    'order'                     => $settings['order'],
    'orderby'                   => $settings['orderby'],
    'post__not_in'              => $duplicated_posts

Fixes it and solves an issue many theme developers overlooked.

I believe this is an incredibly critical piece to any theme that wishes to adhere to today's standards, but many questions omit it.

Adding this clause to the answer is certainly off-topic, yet so important.

What can I do here to help improve the situation, assuming everyone else agrees with me this is an issue?

Here's a rather funny depiction of my view on things:

enter image description here

  • 3
    I would add as a tip that post__not_in is super expensive, and to be avoided at all costs, it's much faster to filter out posts in PHP
    – Tom J Nowell Mod
    Commented Feb 28, 2018 at 10:09

1 Answer 1


Just because an answer has a checkmark ( accepted answer ) does not necessarily mean it's the best solution.

If you feel you have a better solution than the most upvoted or accepted answer you can certainly add your own answer that both:

  1. Answers the original question
  2. Is different enough from other answers so it's isn't mistaken as a duplicate answer

Here you can use your best practices while explaining what you did and why you did it along the way. At this point it's up to the original question asker to review your answer and change the acceptance or up to the community to vote on it.

If it doesn't meet both of the above points then it may be best to leave your addendum as a brief comment.

With that being said it may not always be relevant to add-in information regarding UX and SEO. It's possible that the user doesn't know, does know and doesn't care, or it just isn't relevant in their current situation. Additionally, this is a development Stack Exchange where users primarily ask question pertaining to development and expect to the point answers in a similar fashion. UX and SEO both have their own Exchanges.

Finally, we do have a site-specific chatroom if you would like to discuss WordPress best practices :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .