Problem:
Sort the results by SKU field in the archive page of Woocommerce taxonomy "product category".
Solution:
As a workaround you can override this settings with some custom codes, for example, add below codes into your theme/functions.php:
function sorting_archives($wp_query) { if ($wp_query->is_main_query()&&is_tax('product_cat')) { $wp_query->set('orderby', 'meta_value'); $wp_query->set('meta_key', '_sku'); $wp_query->set('order', 'ASC'); } } add_filter('pre_get_posts', 'sorting_archives', 999);
Relevant Documentation:
https://developer.wordpress.org/reference/hooks/pre_get_posts/
Fires after the query variable object is created, but before the actual query is run.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Our next available supporter will start replying to tickets in about 2.15 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Hong_Kong (GMT+08:00)
This topic contains 6 replies, has 2 voices.
Last updated by 6 years, 7 months ago.
Assisted by: Luo Yang.