Remove Duplicate Pages so only original exists

Basically I have around 4000 pages on my wordpress site and I have identified 1320 are duplicates.

I know I can go select each and every one manually and then bulk move them to the trash etc but does anyone know of a more time efficient way to do this?

Read More

Perhaps a MYSQL query to delete all the duplicates pages?

An example of the urls is as follows:

(Original)

/page/

(Duplicate)

/page-2/ and sometimes even /page-3/

There must be a way to mass delete all pages with the added -2 or -3

Thanks for any and all help.

*edit

It said there was an error with that code however I managed to come up with this…

DELETE a.*
FROM wp_posts AS a
   INNER JOIN (
      SELECT post_title, MIN( id ) AS min_id
      FROM wp_posts
      WHERE post_type = 'page'
      AND post_status = 'publish'
      GROUP BY post_title
      HAVING COUNT( * ) > 1
   ) AS b ON b.post_title = a.post_title
AND b.min_id <> a.id
AND a.post_type = 'page'
AND a.post_status = 'publish'

This managed to get rid of around 550 of the duplicates but for some reason there are still quite a lot of duplicate pages left

I created pages depending on locations and I’ve just realised that I have pages such as

Berwick upon Tweed

and

Berwick-Upon-Tweed

I’d Ideally like to delete the pages with the – in the title as well

Related posts

1 comment

Comments are closed.