Functions.php (WordPress): verschil tussen versies
Naar navigatie springen
Naar zoeken springen
Regel 6: | Regel 6: | ||
############################################################### | ############################################################### | ||
# | # | ||
+ | # * Handy for debugging | ||
# * Source: https://www.wpini.com/delete-all-woocommerce-products/ | # * Source: https://www.wpini.com/delete-all-woocommerce-products/ | ||
# | # | ||
Regel 34: | Regel 35: | ||
} | } | ||
</pre> | </pre> | ||
+ | |||
+ | == Bronnen == | ||
+ | |||
+ | * https://www.wpini.com/delete-all-woocommerce-products/ |
Versie van 7 mei 2019 12:04
Paar functies die ik soms onderbreng in functions.php
############################################################### # dvb_delete_all_products ############################################################### # # * Handy for debugging # * Source: https://www.wpini.com/delete-all-woocommerce-products/ # function dvb_delete_all_products() { global $wpdb; $sql_1 = "DELETE FROM ".$wpdb->prefix."term_relationships WHERE object_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'product');"; $sql_2 = "DELETE FROM ".$wpdb->prefix."postmeta WHERE post_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'product');"; $sql_3 = "DELETE FROM ".$wpdb->prefix."posts WHERE post_type = 'product';"; $sql_4 = "DELETE relations.*, taxes.*, terms.* FROM ".$wpdb->prefix."term_relationships AS relations INNER JOIN ".$wpdb->prefix."term_taxonomy AS taxes ON relations.term_taxonomy_id=taxes.term_taxonomy_id INNER JOIN ".$wpdb->prefix."terms AS terms ON taxes.term_id=terms.term_id WHERE object_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type='product');"; try{ $wpdb->query($sql_1); $wpdb->query($sql_2); $wpdb->query($sql_3); $wpdb->query($sql_4); }catch(Exception $e){} }