【发布时间】:2012-12-19 06:31:21
【问题描述】:
我正在尝试做的事情: 帖子可以分为A类或B类。我想做一个存档,统计有多少帖子被归类为 A,有多少在 B 中,以及总数。
问题: 我的代码算作 A 类的 12 个帖子。B 类算 5。但两个类别都算 12。
为什么?
我的代码:
$posts_a = new WP_Query('cat=5&category__and=30');
$count_a = $posts_a->post_count;
//gives 12
$posts_b = new WP_Query('cat=5&category__and=29');
$count_b = $posts_b->post_count;
//gives 5
$posts_all = new WP_Query('cat=5');
$count_all = $posts_all->post_count;
//gives 12. It should be at least 12+5.
我不想仅仅总结 A+B。我想知道哪里出了问题。
谢谢
【问题讨论】:
-
你的帖子有重叠吗?也就是说,两者都属于?
-
您的意思是,A 类和 B 类的帖子同时发布?不 :(。谢谢!