Last active
October 17, 2023 15:40
-
-
Save Matt-Welland/8809fb3ba00a74bd52e102d416a7fe8e to your computer and use it in GitHub Desktop.
Useful Wordpress SQL Queries - Use at own risk.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE a,c FROM wp_terms AS a | |
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id | |
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id | |
WHERE c.taxonomy = 'product_tag'; | |
DELETE a,c FROM wp_terms AS a | |
LEFT JOIN wp_term_taxonomy AS c ON a.term_id = c.term_id | |
LEFT JOIN wp_term_relationships AS b ON b.term_taxonomy_id = c.term_taxonomy_id | |
WHERE c.taxonomy = 'product_cat'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM wp_woocommerce_order_itemmeta; | |
DELETE FROM wp_woocommerce_order_items; | |
DELETE FROM wp_comments WHERE comment_type = 'order_note'; | |
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' ); | |
DELETE FROM wp_posts WHERE post_type = 'shop_order'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE relations., taxes., terms.* | |
FROM wp_term_relationships AS relations | |
INNER JOIN wp_term_taxonomy AS taxes | |
ON relations.term_taxonomy_id=taxes.term_taxonomy_id | |
INNER JOIN wp_terms AS terms | |
ON taxes.term_id=terms.term_id | |
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product'); | |
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product'); | |
DELETE FROM wp_posts WHERE post_type = 'product'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE wp_options SET option_value = replace(option_value, 'URL-1', 'URL-2') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, 'URL-1','URL-2'); | |
UPDATE wp_posts SET post_content = replace(post_content, 'URL-1', 'URL-2'); | |
UPDATE wp_posts SET post_excerpt = replace(post_excerpt, 'URL-1', 'URL-2'); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'URL-1', 'URL-2'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment