开发者

Loop through custom post type based on value of taxonomy

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 throu开发者_C百科gh 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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜