Quickly identify WordPress posts with duplicate content directly from the MySQL database with a single query

This handy query will return all the post IDs from all your WordPress posts that are exact duplicates.  I usually run this query in a loop and then will delete the newest post duplicate.  This problem usually comes from multiple users importing content into the new WordPress site or importing content from Joomla into WordPress without cleaning the data first.

I go by post content and not just titles, this is a good idea if you have more than 500 articles since there would be a high likelihood that some titles may match but the actual content of those matching title posts could be the same.  This ensures your website does not have duplicate content, which not only will help with your website performance and improve organization of your site, it could drastically improve your SEO rankings since all URLs and content on your site are unique.

//MySQL query -- posts_table is your WordPress "posts" table

SELECT ID FROM posts_table
JOIN (SELECT post_content FROM posts_table
GROUP BY post_content having count(*)>1) dupe
USING (post_content)

Even though there are thousands of plug-ins for WordPress that could accomplish many tasks, I have found that installing a plug-in to perform certain maintenance functions and other admin tasks are cumbersome and unreliable.  The WordPress database structure is very simple and straight forward and it is recommended to try to use single-line database queries that could accomplish the same thing without burdening your website with plug-ins that will slow down your website and cause possible conflicts with the plug-ins you already have installed.

Even for routine maintenance, it is a good idea first to consider running and testing a script that can interface directly with your WordPress database and set up a scheduled CRON job than install another plug-in to perform the same tasks.  Avoid relying too heavily on WordPress plug-ins!  You have been warned!!!

About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

Your email address will not be published. Required fields are marked *