Created
December 26, 2023 14:57
-
-
Save mdibrahimk48/72bfa9c5ca8ef35bd1732df04c993f23 to your computer and use it in GitHub Desktop.
Price wise or default sorting is not working for Woo Product Table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wpt_query_args','wpt_custom_price_wise_sorting_fixer'); | |
/** | |
* If anybody fond that, Price wise sorting is not working for your site | |
* Need to customize product table's args | |
* using filter hook: add_filter('wpt_query_args','wpt_custom_price_wise_sorting_fixer'); | |
* ******************** | |
* wpt_query_args | |
* Very strong filter for Woo Product Table | |
* | |
* @author Ibrahim Khalil <mdibrahimk48@gmail.com> | |
* | |
* @link https://wordpress.org/plugins/woo-product-table/ | |
* @link https://github.com/codersaiful/woo-product-table | |
* @param array $args default array of woo product table. | |
* @return array | |
*/ | |
function wpt_custom_price_wise_sorting_fixer($args){ | |
$args['meta_query'][] = [ | |
'key' => '_price', | |
'compare'=> 'EXISTS', | |
]; | |
$args['orderby'] = 'meta_value_num'; | |
$args['order'] = 'ASC'; | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment