Get the latest taxonomy/category?

The latest edition should always be the term in that taxonomy with the highest term_id, right? Query get_terms and find the latest edition, then use that term to build the rest of your query…

$edition = get_terms('edition','orderby=none&order=DESC&number=1');
$latest_edition = $edition[0]->slug;

Then you can either modify the current query, if that’s what you want to do:

global $wp_query;
$wp_query->set('edition',$latest_edition);

Or use it to build new queries:

$studiesposts = get_posts('category_name=Studies&edition='.$latest_edition);

If you have your permalink structure set up, it should also work to build urls for new links, like this:

http://yourdomain.com/edition/34/category/studies

Leave a Comment