I am creating a function to order a specific custom post type (ex : produit). It works well on the CPT archive page but it doesn't work on the custom taxonomy pages (ex: categories) :
function my_pre_get_posts( $query ) {
// do not modify queries in the admin
if( is_admin() ) {
return $query;
}
// only modify queries for 'produit' post type
if( isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'produit') {
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'irank');
$query->set('order', 'DESC');
}
// return
return $query;
}
add_action('pre_get_posts', 'my_pre_get_posts');
How can I append my code so the custom order applies also to my custom taxonomy pages ?
Thanks a lot