Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm designing a custom magazine theme, where categories are used for different sections, and I created a custom "edition" taxonomy.

The editor will create a new term in that taxonomy for each new edition published, i.e. the number of the issue.

How can I query the latest "edition", so I can combine it with each category and then publish only the posts that belong to the newest edition?

Something along the lines on: ?edition=34&cat=studies

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

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
share|improve this answer
    
That should be the case. Can you help me build that query? thanks! –  Sergio Majluf Nov 15 '10 at 16:00
    
Yeah, I added a few examples above. Hope that helps! –  goldenapples Nov 15 '10 at 18:31
add comment

You can use the plugin Query Multiple Taxonomies.

share|improve this answer
    
Thanks, that´s a good starting point :) –  Sergio Majluf Nov 15 '10 at 17:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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