显示类别 X 中与当前帖子具有相同分类术语的所有帖子

发布于 2024-11-30 00:08:40 字数 270 浏览 3 评论 0原文

我已经几乎可以工作了,有人帮助我完成了一个简洁的片段。目前,尽管它显示所有帖子,无论类别或帖子类型如何,其分类术语与当前帖子相同。我想更改它,以便我可以指定它应该在帖子中循环的类别。

代码如下所示: 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2024-12-07 00:08:40

我使用您的代码来解决同样的问题,并使用以下信息过滤了帖子:

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文