Order archive custom posts by taxonomy term

I cant change the way things are, so I cant use custom meta…

I have terms that are years and I have to display the archive in order (newest to oldest-in terms, not published date) For example the terms are 2007,2008,2009. I need the posts to display first the 2009 ones then the 2008, then the 2007.

I try to add a function to the theme to change the way some posts are displayed with no success. Please help me out! 😀

add_action(‘pre_get_posts’, ‘my_change_sort_order’);

function my_change_sort_order($query)
{
if (is_post_type_archive($post_types = ‘zee_publications’)):
$query->set(‘order’, ‘desc’);

$query->set(get_terms(array(
‘taxonomy’ => ‘cat_publications’,
‘orderby’,
‘slug’
)));
endif;
};

Read more here:: Order archive custom posts by taxonomy term

Leave a Reply

Your email address will not be published. Required fields are marked *