简体   繁体   English

如何使用多个但不是全部标签共同发布

[英]How to get post with multiple but not all tags in common

How do I get posts which have at least two tags in common? 如何获得至少具有两个共同标签的帖子?

tag__in => $args shows posts which have either tag in common tag__in =>的$ args显示了要么标签中常见的帖子

tag__and => $args for post which have all tags in common tag__and => $ args用于发布所有具有共同标签的帖子

What i need is get all posts which have some tags in common, more than one tag and less than all tags in common. 我需要得到的所有帖子都具有一些共同的标签 ,一个以上的标签并且少于所有共同的标签。

Can anyone please help? 谁能帮忙吗?

Thanks in advance! 提前致谢!

Try using the 'tax_query' parameter in WP_Query. 尝试在WP_Query中使用'tax_query'参数。 I haven't tried to do exactly what you're trying to do, but it should work. 我没有尝试完全按照您的意愿去做,但是应该可以。 The tax_query parameter is an array of separate taxonomy queries, with each query specifying the taxonomy, the term_id(s) and an operator like "IN" or "NOT IN". tax_query参数是一组单独的分类法查询,每个查询指定分类法,term_id和一个运算符,例如“ IN”或“ NOT IN”。

Look at WP_Tax_Query in wp-includes/taxonomy.php on line 534 and WP_Query::parse_tax_query in wp-includes/query.php (line 1674). 在第534行的wp-includes / taxonomy.php中查看WP_Tax_Query,在wp-includes / query.php(第1674行)中查看WP_Query :: parse_tax_query。

Here's an example of using tax_query with WP_Query 这是将tax_query与WP_Query一起使用的示例

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM