我需要各个作者发布的最新帖子列表,但按类别过滤,例如撰写有关音乐的作者的最新帖子。
我写了这个查询,看起来像在mysql中工作
SELECT * FROM
(
SELECT *
FROM $wpdb->posts
INNER JOIN
wp_term_relationships ON $wpdb->posts.ID = wp_term_relationships.object_id
WHERE
wp_term_relationships.term_taxonomy_id = 7
AND
$wpdb->posts.post_status = 'publish'
ORDER BY $wpdb->posts.post_date DESC
)
AS x GROUP BY post_author
(7只是一个示例类别ID)
我只想知道调用$wpdb
表的其他wp_term_relationships
函数,以及此查询是否有问题
提前谢谢
答案 0 :(得分:0)
怎么样
$args = array(
'post_type' => 'post',
'cat' => $category_id,
);
$wp_query = new WP_Query($args);