How to bulk delete WordPress posts in a category via SQLThis “How to bulk delete WordPress posts in a category via SQL” article is your definitive guide on how to delete all WordPress posts in one category. Removing posts in WordPress is an easy frontend job but when you’re dealing with thousands to hundreds
of thousands of posts in a category, the task is near to impossible. In this example we will teach you on how to easily complete this difficult job by invoking an SQL query in PHPmyAdmin.How to bulk delete WordPress posts in a category via SQL

How to bulk delete WordPress posts in a category via SQL

➤ How to bulk delete WordPress posts in a category via SQL and phpMyAdmin
    Warning: This tip requires knowledge of SQL and PHPmyAdmin to accomplish. Also, before you proceed with the steps, it is a must to create your database backup in case something in the process goes south.
Copy and Paste the SQL query below to PHPmyAdmin.
delete a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN wp_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id =3333
If in any case you implemented custom table names and databases instead of the WordPress default, replace the value ‘wp_’ with your custom SQL table name, say ‘mydatabase_’. The number ‘3333’ should correspond to the taxonomy ID of your Category name. Making the mistake of typing in the incorrect category ID number can result to inadvertently deleting the wrong posts. Again, create a backup! To apply this tweak, refer to the custom command below:
delete a,b,c,d
FROM mydatabase_posts a
LEFT JOIN mydatabase_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN mydatabase_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN mydatabase_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN mydatabase_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id =3333
For troubleshooting and maintenance purposes, you can invoke the SQL query below before proceeding with deletion query above. This will give you an idea how many posts and entries would be affected by the deletion. Note: replace ‘mydatabase_’ with your custom ‘wp_’ table name.
SELECT *
FROM mydatabase_posts a
LEFT JOIN mydatabase_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN mydatabase_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN mydatabase_term_taxonomy d ON ( d.term_taxonomy_id = b.term_taxonomy_id )
LEFT JOIN mydatabase_terms e ON ( e.term_id = d.term_id )
WHERE e.term_id =3333
Please don’t forget to post your comments below if this works out for you.
posted May 7, 2018 by THE11thROCK for TeraBlitz.com
FAIR USE DISCLAIMER: The following data is for educational, scholarship review and archiving purposes only. By viewing this information, you release the website and its authors from any responsibility or liabilities. Though we verify and maintain the accuracy of the provided data, the absence of unintented typographical and factual errors cannot be guaranteed. Use the page at your own risk. For any suggestions, updates, credits or correction requests, Contact Us: terablitz.rock@gmail.com

TeraBlitz Steam Header Custom Grid Gloss Pack Download

Related Posts

Hot Topics

 up