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.
$args = array(

'post_type' => 'shows',

'operator' => 'AND',

'tax_query' => array(

             array(
                  'taxonomy' => 'location',
                  'field' => 'slug',
                  'term' => 'california',
                  ),  

             array(    
                  'taxonomy' => 'genre',
                  'field' => 'slug',
                  'term' => 'comedy',   
                  )
    )
);

$my_query = new WP_Query();
$my_query->query($args);

while ( $my_query->have_posts() ) : $my_query->the_post();

echo '<li>';
the_title();
echo '</li>';

endwhile;

wp_reset_postdata();

my taxonomy:

register_taxonomy('location',array (
  0 => 'shows',
),array( 'hierarchical' => true, 'label' => 'location','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => 'location'),'singular_label' => 'location') );

register_taxonomy('genre',array (
  0 => 'shows',
),array( 'hierarchical' => true, 'label' => 'genre','show_ui' => true,'query_var' => true,'rewrite' => array('slug' => 'genre'),'singular_label' => 'genre') );

my objective is to display the posts with terms ex. california and comedy, i tried to do the relation but unfortunately no results are displayed

share|improve this question
add comment

1 Answer

In your loop you only call the title using the_title if you want to display the terms of the custom taxonomies you need to call them and the easiest way would be to use get_the_term_list for each taxonomy :

while ( $my_query->have_posts() ) : $my_query->the_post();

echo '<li>';
the_title();
echo get_the_term_list( $post->ID, 'location', 'Location: ', ' ', '' );
echo <br/>
echo get_the_term_list( $post->ID, 'genre', 'Genre: ', ' ', '' );
echo '</li>';

endwhile;
share|improve this answer
    
thanks @Bainternet, but i really want is. I want to show only the posts having terms from location (tax) and genre (tax).. –  adolfozen Aug 23 '11 at 11:44
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.