Answer the question
In order to leave comments, you need to log in
How to speed up selection in wordpress?
add_action( 'pre_get_posts', 'my_change_sort_order');
function my_change_sort_order($query){
if(!is_admin() && $query->is_main_query() ){
if($query->is_archive){
$query->set('orderby', 'meta_value_num');
$query->set('meta_key', 'product_quantity');
$query->set('order', 'DESC');
}
}
}
Answer the question
In order to leave comments, you need to log in
in theory, you can add an index in the database (of course, they are there , but not by custom properties)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question