Answer the question
In order to leave comments, you need to log in
How to remove attributes in bulk?
Hello, can you please tell me how to remove attributes in bulk? I have such a problem, when importing through WP All Import, 16200 attributes were created that are not needed and it is not clear why copies were created
. There are a lot of them, even if you try to manually delete it, deleting 1 such attribute takes 3 minutes and 25 seconds
. There is no access to SQL, you need somehow solve this issue in a artisanal way, if there are none, then tell me some
woocommerce advanced bulk edit options did not help me, since it cannot load due to so many attributes
Answer the question
In order to leave comments, you need to log in
put the php file with the code in the root of the site:
<?php
include 'wp-load.php';
$attributes = json_decode(json_encode(wc_get_attribute_taxonomies()),true);
sort($attributes);
foreach ($attributes as $key => $attribute) {
$deleted = wc_delete_attribute( $attribute['attribute_id'] );
echo '<pre>';
print_r(sprintf('Deleting %s - Result %s',$attribute['attribute_label'], $deleted));
echo '</pre>';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question