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
_stockmeta key to sort products by stock quantity numerically.
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
- Go to Products:
- Navigate to WooCommerce > Products in the WordPress admin.
- View Custom Columns:
- Ensure the new columns (e.g., Stock Quantity and Regular Price) are visible.
- Sort Products:
- Click the column headers to sort the products by stock quantity or regular price.
Example Workflow
| Column Name | Sortable | Data |
|---|---|---|
| Stock Quantity | ? Yes | Numerical value |
| Regular Price | ? Yes | Price 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.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch

