1

I do want to order CTP by year. I have a taxonomy called 'annee' (year), and a CTP called 'moto' (motorbike). Issue is, when im trying to order by the taxonomy, it's ordering only by taxonomy ID, and not by Taxonomy Value. Do you have any solution ?

if ( is_post_type_archive( 'motos' ) ) {

    $query->set( 'posts_per_archive_page', 24 );
    $query->set( 'order', 'DESC' );
    $query->set( 'orderby', 'meta_value_num' );
    $query->set( 'meta_key', 'annee' );
    return;
}   

Thank you.

0

1 Answer 1

0

The meta_key is used to reference a field for a post type, i dont think it will reference the taxonomy of a post type.
Check this out, this may be what you are trying to accomplish:

https://wpshout.com/sort-posts-taxonomy-terms/

Not the answer you're looking for? Browse other questions tagged or ask your own question.