Site icon Hip-Hop Website Design and Development

Order customized put up sort by taxonomy

to all i’ve tried by this code to kind my record customized put up sort by a selected class in ASC approach: (i’ve "model" customized put up sort and that i wanna present order by "model-year" taxonomy

 operate my_pre_get_posts( $question ) {

 // don't modify queries within the admin
 if( is_admin() ) {

return $question;

}

// solely modify queries for 'mannequin' put up sort
if ( $query->is_tax( 'model-year' ) && $query->is_main_query() ) {

$query->set('orderby', 'meta_value');   
$query->set('meta_key', '');    
$query->set('order', 'ASC'); 
}

// return
return $question;

 }

 add_action('pre_get_posts', 'my_pre_get_posts');