根据分类值循环自定义帖子类型

发布于 2024-12-05 23:16:35 字数 170 浏览 4 评论 0原文

我有一个自定义帖子类型常见问题解答和自定义分类类别。

我想循环遍历分类类别,获取其值,然后循环遍历自定义帖子类型常见问题解答并获取具有相同分类值的所有帖子。

任何人都可以阐明这一点吗?

在网上找不到任何像样的样本试图做我想做的事,只有相反的。

干杯, 戴夫

I have a custom post type FAQ and custom taxonomy Category.

I want to loop through the taxonomy Category, take its values, and then loop through custom post type FAQ and grab all the posts that have the same taxonomy values.

Can anyone shed some light on this ?

Can't find any decent samples online that are trying to do what I want, only the opposite.

Cheers,
Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

哥,最终变帅啦 2024-12-12 23:16:35

您也可以通过这种方式

<?php query_posts(array('post_type' => 'post type name', 'Taxonomy slug' => $term->slug ) ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

http:// /techsloution4u.com/code-snippet/how-to-create-custom-taxonomy-loop.html

You can do it on this way also

<?php query_posts(array('post_type' => 'post type name', 'Taxonomy slug' => $term->slug ) ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

Get from http://techsloution4u.com/code-snippet/how-to-create-custom-taxonomy-loop.html

泅渡 2024-12-12 23:16:35

想通了:)只想分享答案:)

$taxonomy_loop = new WP_Query( array( 'taxonomy_name_here' => $taxonomy_value ) );

其中 $taxonomy_value 代表您正在搜索的值。问候,戴夫

Figured it out :) Would just like to share the answer :)

$taxonomy_loop = new WP_Query( array( 'taxonomy_name_here' => $taxonomy_value ) );

Where $taxonomy_value represents the value you are searching for. Regards, Dave

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