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.

Have problems to sort out right information using WP_Query together with Easy Content Types. My query looks like this

<?php
$query = new WP_Query( array( 'post_type' => 'buildarea',  'territory' => 'centrum' ));
while ($query->have_posts()) : 
    $query->the_post();
    echo the_content();
    endwhile; 
// Restore original Post Data
wp_reset_postdata(); ?>

territory is a taxonomy and i want to sort out items belong to "centrum" and to the post-type "buildarea". I also have a post-type called "combuilding" using sam taxonomy. When I use the query i got result from both "combuilding" and "buildarea". What have I done wrong?


Results from var_dump($query->request);

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID 
FROM wp_posts 
INNER JOIN wp_term_relationships 
    ON (wp_posts.ID = wp_term_relationships.object_id) 
    WHERE 1=1 
    AND ( wp_term_relationships.term_taxonomy_id IN (11) ) 
    AND wp_posts.post_type IN ('combuild', 'residential', 'seniorh', 'avapartm', 'add-contact', 'buildarea', 'gen-inf', 'post', 'page') 
    AND (wp_posts.post_status = 'publish' OR wp_posts.post_author = 1 AND wp_posts.post_status = 'private') 
GROUP BY wp_posts.ID 
ORDER BY wp_posts.post_date DESC LIMIT 0, 10
share|improve this question
2  
Please edit you question to include the output of var_dump($query->request);. Also, that {taxonomy} => {term} pattern is deprecated and has been for awhile. You should be using a meta_query. –  s_ha_dum May 21 '13 at 13:48
    
Please use the WYSIWYG editor to format your content. Thanks. –  kaiser May 21 '13 at 14:02

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.