Search code examples
wordpresswoocommercecategoriespermalinksslug

How to change product category slug in bulk in Woocommerce?


I am working on a Woocoomerce site with many categories. I have to add some text at the end of the categories (suffix) slug. Like "klm". How to change product category slug in bulk in Woocommerce?


For example,
Furniture > Kitchen Furniture
The permalink for the category is as follows:
"kitchen-furniture"

What I want to do is add a new text (suffix) to the end of all (main category or subcategories).
For example,
"kitchen-furniture-klm"

Yes, this can be done from wp-admin>Products>Categories. However, as I said at the beginning, there are many categories.

There are 22 pages of entries for categories on Stackoverflow. I've looked at almost all of them. However, I couldn't find what I was looking for. I would appreciate if someone could guide me where to start.


Solution

  • Note: Please take database backup before execute following update query

    You can do this in database, using following query

    UPDATE wp_terms SET slug = CONCAT(slug, '-klm') WHERE term_id IN(SELECT term_id FROM wp_term_taxonomy WHERE taxonomy = 'product_cat')