Home › Forums › Pro Version › Different "Order By" Sorting › Reply To: Different "Order By" Sorting
June 9, 2015 at 1:16 pm #5655
Participant
If i set “Order By default” it just does nothing and keeps listing the posts by date (new-to-old) – WP default. If i select “Order by none” it’s date backwards (old-to-new).
This is the code i put in my functions.php to get the WPeddit order to show up:
//code for changing the custom post order
function wpeddit_order($query) {
global $wp_query;
if ( ! $query->is_main_query() )
return $query;
if(!is_page() || !is_admin()){
if(is_main_query()){
$query->set('meta_key', 'epicredrank');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
}
}
return $query;
}
add_action('pre_get_posts','wpeddit_order');