显示类别 X 中与当前帖子具有相同分类术语的所有帖子
我已经几乎可以工作了,有人帮助我完成了一个简洁的片段。目前,尽管它显示所有帖子,无论类别或帖子类型如何,其分类术语与当前帖子相同。我想更改它,以便我可以指定它应该在帖子中循环的类别。
代码如下所示: http://pastebin.com/pM8aFPQ9
我意识到这可能很容易做到,但我不知道在哪里这段代码我应该指定类别或者我应该如何编写来做到这一点。谁能帮我解决这个问题吗?
I already have this almost working, with a neat snippet someone helped me with. Currently though its displaying all posts regardless of category or post type with the same taxonomy term as the current post. I would like to change it so I can specify which category it should loop in the posts from.
This is what the code looks like:
http://pastebin.com/pM8aFPQ9
I realise this is probably pretty easy to do, but I dont know where in this code I should specify the categories or how I should write to do that. Can anyone help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用您的代码来解决同样的问题,并使用以下信息过滤了帖子:
http://codex.wordpress .org/Class_Reference/WP_Query
使用该页面上的信息,在您指定的 $args 中,您可以添加 'post_type' =>数组('custom_post_type_01','custom_post_type_02');
您还可以使用以下代码指定要包含(或排除)的类别:
'类别名称' => '类别';
您可以在上面的页面上找到更多信息,并且基本上可以使用许多不同的参数来过滤您的帖子。希望这有帮助!
I used your code to solve the same problem and I filtered the posts with info from:
http://codex.wordpress.org/Class_Reference/WP_Query
Using the info on that page, in the $args that you specify, you can add 'post_type' => array('custom_post_type_01', 'custom_post_type_02');
You could also specify which categories to include (or exclude) using this code:
'category_name' => 'category';
You can find more info on the page above and you can essentially filter your posts using lots of different parameters. Hope this helps!