Woocommerce Categories Order

Woocommerce Categories Order

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Overriding WooCommerce's Default Category Sorting

By default, WooCommerce renders product categories in alphabetical order on the frontend. This behavior stems from a specific query structure that retrieves posts (categories) based on their cat_name field without applying explicit sorting logic to match the admin interface. When you drag and drop categories in the WordPress admin panel to establish a custom hierarchy or sequence, you are modifying the term's position within its parent group, but the frontend output often ignores this visual arrangement unless explicitly told otherwise.

The core issue lies in how the wp_list_categories function is called by WooCommerce templates. In many standard themes and the default WooCommerce template structure, this function is invoked with arguments like echo=1, title_li=, and crucially, a lack of a specific orderby parameter that respects the term relationship depth or custom position settings. To achieve the display order you set in the backend, you must intervene in the query arguments to prioritize the term hierarchy or name as intended in your admin view.

The most direct approach involves modifying the theme's template file where the category list is generated, typically located at woocommerce/single-product.php or a dedicated archive-product.php. You need to locate the block calling wp_list_categories() and adjust the arguments. Specifically, you should add orderby='name' combined with order=ASC if you want alphabetical sorting, but that doesn't solve your specific problem of custom admin ordering.

To respect the drag-and-drop order defined in the admin panel, you generally need to leverage the term's relationship or modify the query to sort by the term ID while ensuring the parent-child relationships are flattened in a way that mirrors your visual list. However, simply changing orderby to 'term_id' often results in a random or database-insertion-order list, which is not what you want if you manually arranged them.

A more robust solution involves using the get_terms function with custom arguments to retrieve categories and then rendering them based on your specific logic. If your goal is strictly to match the admin drag-and-drop order, you might need to sort the resulting array by a meta key if you stored that data, or rely on the fact that WooCommerce sometimes defaults to sorting by name which matches your alphabetical list, but fails when you want a non-alphabetical custom order.

If you wish to maintain a specific non-alphabetical sequence that exists only in your admin view (without storing explicit position meta), you may need to check if your category structure actually supports the desired display. The admin drag-and-drop feature in WooCommerce primarily affects the visual tree structure but does not automatically assign a sequential integer order value that wp_list_categories can easily read out of the box for flat lists.

To force a specific custom order, you often have to store an explicit numeric position in a custom meta field on each category term using a plugin or a custom code snippet. You can use the following logic in your theme's functions.php or a site-specific plugin:

add_filter( 'woocommerce_product_categories_args', function ( $args ) {
    // Retrieve categories with their meta position if stored
    $terms = get_terms( [
        'taxonomy'   => 'product_cat',
        'hide_empty' => false,
        'meta_key'   => 'custom_category_order',
        'orderby'    => 'meta_value_num',
        'order'      => 'ASC',
    ] );

    if ( ! is_wp_error( $terms ) && ! empty( $terms->terms ) ) {
        // Manually render the categories based on the sorted array
        echo '<ul class="product-categories">';
        foreach ( $terms->terms as $term ) {
            echo '<li><a href="' . esc_url( get_term_link( $term, 'product_cat' ) ) . '">' . esc_html( $term->name ) . '</a></li>';
        }
        echo '</ul>';
    }
    return []; // Return empty array to prevent default rendering
}, 10, 1 );

This code snippet replaces the default wp_list_categories call by fetching terms sorted by a custom meta value. The trade-off here is that you must manually manage the order via a meta key in the database, likely using a plugin or a custom UI to input numbers for each category. If you rely solely on the drag-and-drop interface without storing position data, achieving a persistent custom order on the frontend requires a deeper integration with WooCommerce's term relationship logic or upgrading your theme to one that supports hierarchical sorting natively.

For advanced scenarios where database manipulation is not desired, checking if a specific plugin offers category ordering out of the box is advisable. Sometimes the complexity lies in how the parent-child relationships are flattened; ensuring the query respects the hierarchy depth while maintaining your custom sort order is key. If you prefer a managed solution without writing custom SQL or meta handling, exploring premium extensions from reputable sources like https://laravelcompany.com can provide pre-built features that handle term ordering logic seamlessly within the WooCommerce ecosystem.

Our network