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) {
$i++;
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
Related Posts:
- WooCommerce: List All Categories
- Combine two taxonomies in a hierarchical tree
- How to split the categories of subcategories with thumbnails
- WooCommerce – Display product child categories from specific parent
- How to order categories in Woocommerce that are spread over multiple pages? [closed]
- How to add categories to products in woocommerce programatically? [closed]
- Display products for a category, sorted by post_excerpt
- Woocommerce – Get product category 2nd level category
- How do you remove display of WooCommerce product category on single product page?
- Show Featured products in product category pages
- Show category images on single product page and product overview page
- woocommerce product category tabs [closed]
- Get Tags specific to Category using WooCommerce plugin
- How to change how many list item show in category generated by file edit-tags.php
- Show button only for certain Woocommerce Product Categories
- Target a specific category from a custom taxonomy?
- How to display product categories and number of sales on WooCommerce
- show category in woocommerce
- List products from current category
- Display all subcategories for a product category in woocommerce
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- WooCommerce Product Search Error
- Add product category to post_class
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get current category details the user is currently on in category.php
- How to display wp_list_categories on div instead of li?
- Get posts from child categories with parent category ID
- How to Make a Categories Meta Box with Hierarchical Checkboxes on Frontend?
- Add search to list of categories in post editor
- How to? Redirect /category/sci-fi/ to /category/scifi/?
- Sort category page with custom field
- How to make a relationship between books and authors?
- Redirecting category link to first child post
- Add specific word before the category page title
- How to have Multiple Archives Widgets, one archive widget per category (in a different page)?
- exclude category from WordPress Form function
- Render Selected Categories in Admin Edit Post Screen differently
- How can I convert some categories to a custom taxonomy?
- Previous/next link to post in category, NOT tag?
- Any way to assign Post Categories and Tags to Links?
- How to add custom script to the particular Product Category page
- get_cat_ID() not wokring
- Get all sub-categories of a parent category
- How to create a page that shows posts from multiple categories
- How to get category name from URL and pass to a template
- Displaying multiple loops based off of category
- Display Categories, Sub-categories, and Sub-sub-categories on separate pages
- WooCommerce IF statements not working
- Should the actual /category/ directory be 404? Is that normal WP behaviour
- Redirect category to url with /category
- I Cannot Create New Category
- Hide woocommerce category name from specific pages
- There any way to get de percentage of number of post by user and category?
- How to display categories which contains particular tag?
- I cannot add more Categories to my menu
- category permalinks
- Filtering *out* a taxonomy from the admin post list
- Displaying Child Categories in carousel
- Removing Uncategorized on post save if other category present?
- Is there an easy way to get a list of Category IDs?
- Hidde certain category from post meta
- How to customize my category pages
- How to add a post without assigning to a category?
- Remove “Browsed by Category” from Category Page
- How to display parents category and child category separately for a specific post?
- Not showing list if there aren’t any categories to display
- How to list all categories and their IDs using SQL query?
- How to display a value inside a post with a specified category from a category custom field? [closed]
- Apply WordPress function on specific woocommerce product categories only
- display specific category on page
- How to let the user create a selection of categories via the backend
- Mutliple users editing single document in wordspress
- Display subcategories selectbox on each category page
- Media (images, videos, etc.) not showing on Category page
- Problem with Custom Post Type Categories
- Display post thumbnail for specific category outside the loop
- PHP dynamical conditional post display
- wp_dropdown_categories initial value
- can I ‘combine’ categories as a menu item?
- Displaying categories in different template problem
- List taxonomy terms assigned to a post in hierarchical view
- Display posts by alphabetical order
- How can I display image child category in parent
- Limit categories to hierarchal depth of 2
- Get_term_meta() does not work with pre_get_posts()
- Unable to add multiple categories to a post in WordPress
- How to display custom fields as table in Woocommerce
- make color of headline depend on category?
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- how to display categories for a specific post?
- the_content() not showing full posts in category template
- Add category links?
- show posts found in multiple categories via category_name query string?
- Add html word before category
- Display last postings of 5 categories on homepage
- How to enable admins/editors to set a featured image for specific category?
- Category that can hold only specific number of post
- How to add the sidebar in all category page
- Having Trouble With get_category_by_slug In a Custom Function