Remove/Look for Duplicate posts in WordPress

How to delete duplicate posts in wordpress database:

Login to phpmyadmin and execute the following query:

DELETE bad_rows.* from wp_posts as bad_rows inner join (select post_title, MIN(id) as min_id from wp_posts group by post_title having count(*) > 1) as good_rows on good_rows.post_title = bad_rows.post_title and good_rows.min_id <> bad_rows.id

or if you want just to have a look at the rows.

SELECT bad_rows.*
from wp_posts as bad_rows
inner join (
select post_title, MIN(id) as min_id
from wp_posts
group by post_title
having count(*) > 1
) as good_rows on good_rows.post_title = bad_rows.post_title
and good_rows.min_id <> bad_rows.id

Leave a Reply

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