How to Bulk Delete Duplicate Posts From Two Wordpress Sites?

8 minutes read

To bulk delete duplicate posts from two WordPress sites, you can follow these steps:

  1. Backup your databases: Before performing any bulk deletion, make sure to create a complete backup of both WordPress databases. This ensures that you have a restore point in case anything goes wrong.
  2. Identify duplicate posts: Start by identifying which posts are duplicates across both sites. You can do this by comparing post titles, content, or any other unique identifiers. It's important to have a clear understanding of which posts you want to delete.
  3. Access your database: Log in to the database management tool provided by your web hosting service or use a tool like phpMyAdmin to access the databases of your WordPress sites.
  4. Execute a database query: Run a custom database query to identify and select the duplicate posts. The query will depend on how you want to identify duplicates. For example, if you decide to compare post titles, the query may look like this: SELECT * FROM wp_posts WHERE post_title IN ( SELECT post_title FROM wp_posts GROUP BY post_title HAVING COUNT(post_title) > 1 ); Replace wp_posts with the appropriate table prefix for your WordPress installation.
  5. Review the results: The query will provide a list of duplicate posts based on your criteria. Review the results to ensure that only the intended duplicate posts are selected. It's crucial to double-check this step to avoid accidental deletion of important content.
  6. Back up the affected posts: If you want to keep a copy of the duplicate posts, export them to a separate file. This way, you can restore them later if needed.
  7. Delete the duplicate posts: Execute a delete query to remove the selected duplicate posts from your database. Be careful with the query to avoid deleting the wrong posts. The delete query may look like this: DELETE FROM wp_posts WHERE post_title IN ( SELECT post_title FROM wp_posts GROUP BY post_title HAVING COUNT(post_title) > 1 ); Again, replace wp_posts with your table prefix.
  8. Verify the deletion: After executing the query, check the site's frontend and backend to confirm that the duplicate posts are successfully deleted. Perform a thorough check to ensure everything is working as expected.


Remember to always exercise caution when working directly with databases. It's highly recommended to have a good understanding of WordPress database structure and to backup your data before making any changes.

Best WordPress Hosting Providers in December 2024

1
Vultr

Rating is 5 out of 5

Vultr

  • Ultra-fast Intel Core
  • Low Price and High Quality
  • High Performance and Cheap Cloud Dedicated Servers
2
Digital Ocean

Rating is 4.9 out of 5

Digital Ocean

  • Active Digital Community
  • Simple To Use
  • Starting as low as 5$ per month
3
AWS

Rating is 4.8 out of 5

AWS

4
Cloudways

Rating is 4.7 out of 5

Cloudways


How to bulk delete duplicate posts using SQL queries in WordPress?

To bulk delete duplicate posts using SQL queries in WordPress, follow these steps:

  1. Before making any changes, it is recommended to backup your WordPress database for safety.
  2. Access your WordPress database using a tool like phpMyAdmin or any other database management tool.
  3. Identify duplicate posts by looking at their content, titles, or other identifying factors.
  4. Run the following SQL query to identify duplicate posts based on their content:
1
2
3
4
5
SELECT post_title, COUNT(*) as count
FROM wp_posts
WHERE post_type = 'post'
GROUP BY post_title
HAVING count > 1;


  1. Review the results of the query and note down the duplicate post IDs that you want to delete. Make sure you are only marking the duplicate posts and not the original ones.
  2. Run the following SQL query to delete the duplicate posts (replace x, y, z with the duplicate post IDs):
1
2
3
DELETE p FROM wp_posts AS p
LEFT JOIN wp_postmeta AS pm ON p.ID = pm.post_id
WHERE p.post_type = 'post' AND p.ID IN (x, y, z);


  1. If you want to also delete the corresponding postmeta (custom fields) of the duplicate posts, run the following SQL query (replace x, y, z with the duplicate post IDs):
1
2
3
DELETE pm FROM wp_postmeta AS pm
LEFT JOIN wp_posts AS p ON pm.post_id = p.ID
WHERE p.ID IN (x, y, z);


  1. After executing the queries, verify that the duplicate posts have been deleted from your WordPress installation.


Note: SQL queries can have serious consequences if not executed correctly. It is crucial to backup your database and proceed with caution.


How to bulk delete duplicate posts from two WordPress sites?

There are a few different approaches you can take to bulk delete duplicate posts from two WordPress sites. Here are two methods you can try:

  1. Use a plugin: Install and activate a plugin like "Duplicate Post Delete", "Bulk Delete", or "Duplicate Posts Remover". Navigate to the plugin's settings page within your WordPress dashboard. Connect both of your WordPress sites (if the plugin supports it) or log in to each site individually. Choose the duplicate post detection method (based on title, content, etc.) and configure the options according to your needs. Run the plugin and it will identify and delete the duplicate posts from both sites simultaneously.
  2. Utilize a database query: Note: This method requires some technical knowledge and should only be attempted by experienced users. Make sure to backup your database before proceeding. Access the database of one of your WordPress sites using a tool like phpMyAdmin or Adminer. Identify which table contains the post data. Usually, it will be named "wp_posts" (replace "wp_" with your WordPress table prefix if it differs). Run a database query to identify the duplicate posts based on post content, title, or any other factor. For example, you can use a query like this: SELECT post_title, COUNT(*) AS duplicates FROM wp_posts WHERE post_type = 'post' GROUP BY post_title HAVING duplicates > 1; The query will provide you with a list of duplicate posts. Take note of their IDs. Next, construct a query to delete these duplicate posts. Ensure you have the correct IDs before proceeding. For example: DELETE FROM wp_posts WHERE ID IN (duplicate_post_id_1, duplicate_post_id_2, ...); Execute the query, and the duplicate posts will be deleted from the site's database. Repeat the above steps for the other WordPress site as well.


Regardless of the method you choose, it's essential to review the detected duplicate posts before deleting them to ensure no valuable content is accidentally removed.


What is the difference between duplicate posts and similar content in WordPress?

Duplicate posts in WordPress refer to two or more posts that have exactly the same content. These could be intentionally created duplicates or accidental duplicates, often caused by copying and pasting content from one post to another.


Similar content in WordPress, on the other hand, refers to posts that have similar or related content but are not exact duplicates. These posts may have different titles, slightly different content, or variations in the layout or formatting.


In summary, duplicate posts have identical content, while similar content refers to posts that share similarities but are not exactly the same.

Facebook Twitter LinkedIn Whatsapp Pocket

Related Posts:

Filtering posts in WordPress by category can be achieved through several methods. One way is by using the built-in category functionality provided by WordPress. Here's how you can do it:Open your WordPress dashboard and navigate to "Posts" in the s...
Do you wish to delete a WordPress theme however are fearful that it is likely to be unsafe? When you’ve got not too long ago switched your WordPress theme, then you could wish to delete the previous one. You might also have a number of different WordPress the...
To filter posts by tag name in the WordPress API, you can follow these steps:Retrieve the list of available tags using the /wp/v2/tags endpoint. This will provide you with the tag names and corresponding IDs.Identify the ID of the tag you want to filter by.Use...
There is no fixed limit on the number of WordPress sites that you can run on one server. The number of WordPress sites you can host largely depends on various factors such as the server's hardware, its specifications, and resource usage by each WordPress s...
Do you need to setup wholesale pricing in WooCommerce for bulk purchases and wholesale consumers? By default, WooCommerce solely lets you set regular pricing for a product. On this article, we are going to present you the way to simply setup WooCommerce whole...
To delete a WordPress theme, follow these steps:Log in to your WordPress admin dashboard.Go to the "Appearance" section and click on "Themes."You will see a list of all the installed themes on your website. Locate the theme you want to delete.H...