admin管理员组文章数量:1122846
Is it possible to delete the global product attributes in WooCommerce by using WP-CLI?
I've often cleared out Users, Orders, and other items using something like this...
wp post delete $(wp post list --post_type='shop_order' --format=ids) --force
But I can't seem to find or figure out a good way to sort that for attributes.
I'm specifically referring to the attributes you configure under 'Products => Attributes' in the WordPress Dashboard not the ones that are added inline on products.
Is it possible to delete the global product attributes in WooCommerce by using WP-CLI?
I've often cleared out Users, Orders, and other items using something like this...
wp post delete $(wp post list --post_type='shop_order' --format=ids) --force
But I can't seem to find or figure out a good way to sort that for attributes.
I'm specifically referring to the attributes you configure under 'Products => Attributes' in the WordPress Dashboard not the ones that are added inline on products.
Share Improve this question asked Jun 27, 2024 at 18:05 fyrekcazfyrekcaz 32 bronze badges1 Answer
Reset to default 0As we know WooCommerce product
attributes are stored in a custom taxonomy, It means we need to work with taxonomies
and terms instead of posts. WP-CLI
provides commands for working with taxonomies
and terms that can be used for this purpose.
We are going to follow the given steps: List all global product attributes > Delete all terms in each global attribute taxonomy
We will use the given CLI to list out all taxonomies so we can identify our attribute taxonomies.
wp taxonomy list --format=json | jq '.[] | select(.name | startswith("pa_"))'
We will use given CLI to delete all terms we have in a specific taxonomy.
wp term list pa_color --field=term_id | xargs wp term delete pa_color
Here we need to replace pa_color
with the actual taxonomy
you want to delete
terms from.
本文标签: wp cliBulk delete 39Global Attributes39 in WooCommerce via WPCLI
版权声明:本文标题:wp cli - Bulk delete 'Global Attributes' in WooCommerce via WP-CLI? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302421a1931527.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论