category__and
是独占的,因此如果您使用tax_query
并按如下方式设置查询,它应该可以工作:
$args = array(
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'category\',
\'field\' => \'id\',
\'terms\' => $city,
//\'include_children\' is true by default
),
array(
\'taxonomy\' => \'category\', //may need to be categories, I don\'t recall, tweak it till it works.
\'field\' => \'id\',
\'terms\' => $category,
//\'include_children\', again, is true by default
)
)
);
$posts = query_posts( $args );
如果这不符合
query_posts()
(我看不出有任何理由不这样做),
WP_Query
不会抱怨的,所以就用这个吧。还有,链接到
WP_Query
包含了修改该查询所需的所有文档,所以浏览一下,您可能至少需要
\'post_status\' => \'publish\'
...也许更多。