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 have a pretty extensive music collection and my friends are always borrowing my stuff. I would like to keep better track of my library so I'm building a sudo-checkout system using WP.

The collection was already in WP using terms to sort everything. The main taxonomies are artist, year released, label, and genre. I want to add a new taxonomy called whereisit. The post type used is called album.

Because of the way that other plugins interact with the site (I'm a music geek) I can't easily use post meta for inventory status term. If it matters at the moment I'm using Scribu's plugin to autogenerate taxonomy search fields.

The question:

How can I display a list of terms who's related posts also match another fixed term?

For example: Show a list of terms for artists who's whereisit term is ihaveit. If all of the artist's albums have an whereisit term of idonthaveit, do not display the artist term in the list.

Or more simply: If all of my albums by a particular artist are loaned out to someone else, don't display the artist's name in the Artist list.

Would something like this have to be done through wpdb? Filtering a loop is easy enough, but translating that to a list is over my head. :)

Edit: I replaced the terms inhouse with ihaveit, checkedout with idonthaveit, and the taxonomy named inventorystatus with whereisit for better clarity.

share|improve this question
    
you lost me at "If the term inhouse is checkedout" –  Bainternet Jun 3 '11 at 22:19
    
@Bainternet I simplified the term names, hopefully this easier to follow now. :) –  mattrepublic Jun 5 '11 at 14:25
    
So you want a list of albums by artist that are ihaveit? –  Bainternet Jun 5 '11 at 15:46
    
@bainternet yes, that is correct. –  mattrepublic Jun 5 '11 at 20:16
add comment

1 Answer 1

up vote 0 down vote accepted

if i understand correctly you want to get a list of albums (posts) of a specific artist(taxonomy) and that are have ihaveit term.

if so the its a simple query using tax_query:

$args = array(
    'posts_per_page' => -1, //get all
    'post_type' => 'album', 
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'artist',
            'field' => 'slug', 
            'terms' => array( 'artist-slug' )
        ),
        array(
            'taxonomy' => 'whereisit',
            'field' => 'slug',
            'terms' => array('ihaveit')
        )
    )
);
$query = new WP_Query( $args );
while($query->have_posts())
{
    $query->the_post();
    //to your thing / loop here
}
share|improve this answer
    
You phrased what I am trying to accomplish correctly but were are taking different meaning from it. My hope with this ticket is to create a list of taxonomies in a select menu that could then be searched. Related WP functions might be for example (to display all taxonomy terms), use the_terms, get_the_term_list, or wp_list_categories. –  mattrepublic Jun 6 '11 at 12:38
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.