我一直在努力使下面的代码工作,但它只是不起作用,我想知道可能是什么原因。
$args = array(
'post_type' => 'project',
'tax_query' => array(
array(
'taxonomy' => 'categories_project',
'field' => 'slug'
)
)
);
$wp_query = new WP_Query( $args );
正在运行<?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
任何帮助都将得到极大的帮助。 谢谢!
答案 0 :(得分:0)
好的,我发现了这个问题,它需要一个术语!....
$args = array(
'post_type' => 'project',
'tax_query' => array(
array(
'taxonomy' => 'categories_project',
**'terms' => $term,**
'field' => 'slug'
)
)
);
$wp_query = new WP_Query( $args );