WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to sort product categories?

I have a category with a lot of subcategories. On the category page all the subcategories is listed. Right now I can only change the order by drag and drop in the admin panel. But that is very time consuming with a lot of categories. Any way to change the order without using drag and drop?

share|improve this question

closed as off-topic by cybmeta, Mayeenul Islam, Pieter Goosen, Howdy_McGee, TheDeadMedic Apr 1 '15 at 17:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

Did I ask the question in a wrong way? I got a minus, but I'm not sure why. Something I should change or have missed? – EmilF Jan 12 '13 at 20:20
up vote 2 down vote accepted

Woocommerce stores 'order' metakeys in the table wp_woocommerce_termmeta. The mechanism it uses is the same as menu_order for posts.

Something like this should work:

$terms = get_terms('product_cat');

//sort $terms somehow

$i = -1;

foreach ($terms as $term) {
  update_woocommerce_term_meta( $term->id, 'order', $i);

The same procedure can be used to sort other Woocommerce taxonomies such as product_tag and Product Attributes. For a Product Attribute named Size, the taxonomy would be pa_size, and you should replace 'order' by order_pa_size

share|improve this answer
I would +2 that answer if I could – Ben Nov 24 '14 at 6:39

You can sort product categories by drag-and-drop. Notice that your mouse cursor turns into a hand when over a category row? Grab it and drag to its new position in the list. Job is done.

share|improve this answer
Yeah, I have just done it with drag and drop. It does however take a long time with over 100 categories. Thanks for the answer. – EmilF Jan 12 '13 at 20:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.