PHP Woocommerce Wordpress

Delete all attribute name in woocommerce

To delete all attribute names in woocommerce

<?php require('wp-load.php');
	function delete_all_attribute_name(){
		global $wpdb;
		$exclude = array(2,1292,143,1293,1295,1294);
		echo $query = "select `attribute_id` from `".$wpdb->prefix."woocommerce_attribute_taxonomies` ";
		$result = $wpdb->get_results($query);
		foreach ($result as $res) {
			if(!in_array($res->attribute_id,$exclude)){
				echo "\n".$res->attribute_id.": to be deleted\n";
				$b = wc_delete_attribute( $res->attribute_id );
			}	echo "\n Deleted: ".$b." id : ".$res->attribute_id."\n";
		}
	}

if(php_sapi_name() === 'cli'){
  delete_all_attribute_name();
}else{
  die('Access did not allowed');
}
?>

Leave a Reply

Your email address will not be published. Required fields are marked *


CAPTCHA Image
Reload Image