显示来自 x cat 和 y tag 的帖子
是否可以获取与类别 x“AND”标签 y 匹配的帖子?
阅读文档,似乎您可以这样做:
query_posts('tag=bread,baking');
或者
query_posts('cat=2,6,17,38');
...是否可以同时使用 cat 和 tag?
Is it possible to fetch posts matching categorie x "AND" tag y?
Read the docs, it seems you can do:
query_posts('tag=bread,baking');
or
query_posts('cat=2,6,17,38');
... is it possible to use both cat and tag simultaneously?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不是 WordPress 专家,但我通过查找该函数看到的是,您应该能够使用此表示法以便同时查询两者。
I am not a Wordpress expert, but what I see from looking up that function, is that you should be able to use this notation in order to query against both at the same time.
这是取自我之前回答过的另一个问题,它已经过测试并且工作正常,所以我们开始吧。您可以使用以下方法手动查询数据库:
您要做的就是为要查找的每个标签/类别提供 termID。
我不确定它是否有效,但从技术上讲,标签和类别位于同一个表中。所以,我认为如果你在 cat= 参数中提供 tagID 它可能会起作用,我目前没有机会测试它,但绝对值得一试。
This is taken from another question that I had answered previously and it was tested and worked properly, so here we go. You can manually query your database using the following:
All that you would do is that you would provide the termID for each of the tags/categories that you want to find.
I'm not sure if it would work or not, but technically tags and categories are within the same table. So, I would think that if you provide the tagID within the cat= parameter it might work, I don't have a chance to test it currently, but definitely worth a try.
是的,你可以。我最近不得不在我的 WordPress 日志页面上显示所有未来的帖子,我只是使用了:
它工作得完美无缺。
Yes, you can. I recently had to show all future posts on a page of my wordpress log and I just used:
which worked flawlessly.