How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026

Last updated on January 3rd, 2025 at 08:16 am

Managing products efficiently in WooCommerce often requires custom sorting options in the admin product list. Whether you want to sort products by stock quantity, custom fields, or a specific attribute, adding custom sorting options can significantly improve your workflow.

In this guide, we’ll show you how to add custom sorting options to the WooCommerce admin product list without using a plugin.


Step 1: Add a Custom Column to the Product List Table

The first step is to create a custom column that displays the data you want to sort. For example, if you want to sort products by stock quantity, you’ll need to add a column for stock values.

Code to Add a Custom Column

Add this code to your theme’s functions.php file or your child theme:

/*
 * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function adds a custom column to the admin product list"
*/ function wcsuccess_add_custom_product_column( $columns ) { $columns['stock_quantity'] = __( 'Stock Quantity', 'woocommerce' ); return $columns; } add_filter( 'manage_edit-product_columns', 'wcsuccess_add_custom_product_column' ); /* * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function displays data in the custom column"
*/ function wcsuccess_display_custom_product_column( $column, $post_id ) { if ( 'stock_quantity' === $column ) { $stock_quantity = get_post_meta( $post_id, '_stock', true ); echo is_numeric( $stock_quantity ) ? $stock_quantity : __( 'N/A', 'woocommerce' ); } } add_action( 'manage_product_posts_custom_column', 'wcsuccess_display_custom_product_column', 10, 2 );

Explanation:

  • Custom Column: Adds a new column named Stock Quantity to the admin product list.
  • Display Data: Fetches and displays the stock quantity for each product.

Step 2: Make the Column Sortable

Once the custom column is added, you need to make it sortable.

Code to Enable Sorting

Add this code to your functions.php file:

/*
 * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function makes the custom column sortable"
*/ function wcsuccess_make_custom_column_sortable( $sortable_columns ) { $sortable_columns['stock_quantity'] = 'stock_quantity'; return $sortable_columns; } add_filter( 'manage_edit-product_sortable_columns', 'wcsuccess_make_custom_column_sortable' ); /* * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function adds sorting functionality to the custom column"
*/ function wcsuccess_sort_products_by_stock_quantity( $query ) { global $pagenow; if ( 'edit.php' === $pagenow && isset( $query->query_vars['post_type'] ) && 'product' === $query->query_vars['post_type'] ) { if ( isset( $query->query_vars['orderby'] ) && 'stock_quantity' === $query->query_vars['orderby'] ) { $query->set( 'meta_key', '_stock' ); $query->set( 'orderby', 'meta_value_num' ); } } } add_action( 'pre_get_posts', 'wcsuccess_sort_products_by_stock_quantity' );

Explanation:

  • Sortable Columns: Registers the custom column as sortable.
  • Sorting Logic: Uses the _stock meta key to sort products by stock quantity numerically.
See also  How to improve Woocommerce mobile checkout by adding quick navigation buttons

Step 3: Add Additional Sorting Options

You can extend this functionality to sort products by other fields, such as price, SKU, or a custom meta field.

Example: Sort by Regular Price

Add this code to your functions.php file to add sorting by Regular Price:

/*
 * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function adds a custom column for regular price"
*/ function wcsuccess_add_regular_price_column( $columns ) { $columns['regular_price'] = __( 'Regular Price', 'woocommerce' ); return $columns; } add_filter( 'manage_edit-product_columns', 'wcsuccess_add_regular_price_column' ); /* * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function displays the regular price in the custom column"
*/ function wcsuccess_display_regular_price_column( $column, $post_id ) { if ( 'regular_price' === $column ) { $regular_price = get_post_meta( $post_id, '_regular_price', true ); echo wc_price( $regular_price ); } } add_action( 'manage_product_posts_custom_column', 'wcsuccess_display_regular_price_column', 10, 2 ); /* * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function makes the regular price column sortable"
*/ function wcsuccess_make_regular_price_sortable( $sortable_columns ) { $sortable_columns['regular_price'] = 'regular_price'; return $sortable_columns; } add_filter( 'manage_edit-product_sortable_columns', 'wcsuccess_make_regular_price_sortable' ); /* * Snippet: How to Add Custom Sorting Options to WooCommerce Admin Product List – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1831
* Tested with WooCommerce 10.7.0
* "This function adds sorting logic for regular price"
*/ function wcsuccess_sort_products_by_regular_price( $query ) { global $pagenow; if ( 'edit.php' === $pagenow && isset( $query->query_vars['post_type'] ) && 'product' === $query->query_vars['post_type'] ) { if ( isset( $query->query_vars['orderby'] ) && 'regular_price' === $query->query_vars['orderby'] ) { $query->set( 'meta_key', '_regular_price' ); $query->set( 'orderby', 'meta_value_num' ); } } } add_action( 'pre_get_posts', 'wcsuccess_sort_products_by_regular_price' );

Step 4: Test Your Custom Sorting Options

  1. Go to Products:
    • Navigate to WooCommerce > Products in the WordPress admin.
  2. View Custom Columns:
    • Ensure the new columns (e.g., Stock Quantity and Regular Price) are visible.
  3. Sort Products:
    • Click the column headers to sort the products by stock quantity or regular price.
See also  How to Create a Custom Product Badge for Best Sellers in WooCommerce - 2026

Example Workflow

Column NameSortableData
Stock Quantity? YesNumerical value
Regular Price? YesPrice formatted

Use Case Example

  • Sort products by stock quantity to identify low-stock items.
  • Sort products by regular price to manage pricing more effectively.

Conclusion

Adding custom sorting options to the WooCommerce admin product list allows you to tailor the admin interface to your needs. By following this guide, you can create new columns, display custom data, and sort products by any field, such as stock quantity or price.

Test these changes in a staging environment before applying them to your live site. For more WooCommerce customisation options, explore our WooCommerce Visual Hooks Guide or use our wp-config generator for advanced configurations.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×