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 trying to show all the posts associated with a Taxonomy (not a term) but it seems to not work.

<?php

$args = array(
    'post_type' => 'projects',
    'tax_query' => array(
        array(
            'taxonomy' => 'clients',
            'terms' => 'Unilever'
        )
    )
);
$the_query = new WP_query();
$the_query->query($args);

if($the_query->have_posts()):while($the_query->have_posts()):$the_query->the_post();

php the_title();


endwhile; endif;
wp_reset_query();

?>
share|improve this question
    
You should use wp_reset_post_data instead of wp_reset_query when using WP_Query objects codex.wordpress.org/Function_Reference/wp_reset_postdata –  Tom J Nowell Oct 3 '11 at 14:53

2 Answers 2

up vote 1 down vote accepted

You haven't specified the 'field' value e.g. 'field' => 'slug',

http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

share|improve this answer

In case anyone else is looking for the answer:

$args = array( 'post_type' => 'projects', 'tax_query' => array( 'taxonomy' => 'clients' ) );

share|improve this answer

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.