Woocommerce Categories Order
Asked Answered
K

6

10

I am trying to re-order my categories from the default alphabetical order.

My admin backend my categories look like this:

enter image description here

And on the frontend they they look like this:

enter image description here

Is it possible to have them displayed in the way I have sorted them in the backend?

Kalmuck answered 25/4, 2016 at 8:17 Comment(0)
G
14

The Category Order and Taxonomy Terms Order plugin will allow you to do this. It'll add a drag-and-drop sortable interface to the backend where the changes you make will take effect both on the backend and the frontend.

Glennieglennis answered 25/4, 2016 at 8:51 Comment(3)
This plugin is no longer supported or does not work. ( wordpress.org/support/topic/cant-save-order-any-more )Condor
What if I need to sort my search results this way on my custom page-search page with Wp_Query? I don’t see it working.Bondsman
@Trip, looks like it came back to working order... Last Update: 4 weeks agoKnute
B
9

And if you display your categories with the Woocommerce shortcode there is even simpler way to do it - add orderby="menu_order" to the shortcode. So for me it looks like this:

echo do_shortcode( '[product_categories orderby="menu_order"]' )
Botanist answered 25/5, 2019 at 23:3 Comment(0)
N
6

add this to your args list

$args = array(
       
          'orderby'=>"menu_order",
  );

Within the array used for the loop's arguments uses native Wordpress functionality to accomplish the OP's goals... rather than installing yet another plugin where it's not needed. "Thank you :@aronmoshe_m"

Nightie answered 27/9, 2020 at 22:49 Comment(2)
Code-only answers are discouraged on Stack Overflow because they don't explain how it solves the problem. Please edit your answer to explain what this code does and how it can be used to answer the question, so that it is useful to the OP as well as other users with similar issues.Artima
This answer should have more explanation to be helpful to the OP, but this is the best answer on here. Using 'orderby' => 'menu_order', within the array used for the loop's arguments uses native Wordpress functionality to accomplish the OP's goals... rather than installing yet another plugin where it's not needed.Mayolamayon
E
1

While the approved answer works, there is another way using default woo functionality with no additional plugins. First look into: get_woocommerce_term_meta( $sub_category->term_id, 'order', true )

Then get all your categories and sort the array using this order.

$sortedMenu = array(); // new array
// menu var should be get_categories or taxonomy function return
// I also added order key/val in my category/term array item (along with other terms name, id etc)
// Then I sorted them like bellow
foreach( $menu as $key => $item ) $sortedMenu[$key] = $item['order'];
array_multisort( $sortedMenu, SORT_ASC, $menu );
Elasticity answered 28/8, 2018 at 13:20 Comment(0)
T
0

Just for reference, here is the woocommerce documentation on Product Categories. https://woocommerce.com/document/woocommerce-shortcodes/product-category/

One can change the menu order by dragging and dropping the categories in the backend.

I used this shortcode to display just the categories I want and in the order I wanted it to be displayed. [product_categories ids="46,99,98,59,97" orderby="menu_order"]

Therefor answered 31/7, 2024 at 7:2 Comment(0)
D
-1

I do believe you might need an additional plugin to further customize sorting options for categories.

Try looking up Woocommerce Product Archive Customizer or similiar plugins if you do not have any similar functionality in the theme you're using.

Disillusionize answered 25/4, 2016 at 8:35 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.