我需要知道给定类别和meta_values的帖子数量。我不想使用获取帖子,因为它实际上检索了一组帖子对象,我只需要知道帖子的数量,我不需要所有的帖子数组的开销(结果可能是数千的顺序)
这些是需要满足的条件:
- 类别是“user_stats”
和
-Meta_key是“start_time”,meta_value大于“y”且小于“z” (“y”和“z”是整数)
和
-Meta_key是“seller_id”,meta_value是“123456778”
我需要的是执行它的sql语句(下面的代码不起作用):
$sql_statements="SELECT count(DISTINCT wp_postmeta.`post_id`)
FROM wp_posts
LEFT JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
LEFT JOIN wp_term_relationships ON (wp_posts.ID =
wp_term_relationships.object_id)
LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id
= wp_term_taxonomy.term_taxonomy_id)
WHERE wp_postmeta.meta_key = 'seller_nickname'
AND wp_postmeta.meta_value >= '1523656442'
AND wp_postmeta.meta_value <= '1523656529')";
$query = $wpdb->get_results($sql_statements);
提前致谢