[英]tax_query not working with WP_Query
i have been trying so hard to make the following code to work but it just doesnt work, I am wondering what could be the reason. 我一直在努力使以下代码工作,但它根本无法正常工作,我想知道这可能是原因。
$args = array(
'post_type' => 'project',
'tax_query' => array(
array(
'taxonomy' => 'categories_project',
'field' => 'slug'
)
)
);
$wp_query = new WP_Query( $args );
Running <?php echo $GLOBALS['wp_query']->request; ?>
运行
<?php echo $GLOBALS['wp_query']->request; ?>
<?php echo $GLOBALS['wp_query']->request; ?>
gets me this: <?php echo $GLOBALS['wp_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 (53) )
AND wp_posts.post_type = 'project'
AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC
LIMIT 0, 3
Any help will be highly appreacited. 任何帮助将不胜感激。 Thanks!
谢谢!
Ok i found of the problem, it needs to have a term!.... 好的,我发现了问题,它需要一个学期!
$args = array(
'post_type' => 'project',
'tax_query' => array(
array(
'taxonomy' => 'categories_project',
**'terms' => $term,**
'field' => 'slug'
)
)
);
$wp_query = new WP_Query( $args );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.