How to loop for posts only with certain taxonomy?
-
I have a CPT “classes” with a taxonomy “series”. I am trying to use your plugin (thanks for it!) to only show classes with a series of “My New Series”. I have tried you examples and can’t seem to properly code the certain taxonomy.
This, displays nothing:
<ul> <?php foreach (get_the_terms(('series'), 'My New Series') as $cat) : ?> <li> <img class="img-responsive" src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> <a class="fusion-no-lightbox" href="<?php echo get_term_link($cat->slug, 'series'); ?>"><?php echo $cat->name; ?></a> </li> <?php endforeach; ?> </ul>
This, displays all classes (posts) with any series (tax):
<ul> <?php foreach (get_the_terms('series') as $cat) : ?> <li> <img class="img-responsive" src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /> <a class="fusion-no-lightbox" href="<?php echo get_term_link($cat->slug, 'series'); ?>"><?php echo $cat->name; ?></a> </li> <?php endforeach; ?> </ul>
How do i loop through posts only that have taxonomy “My New Series”?
Thanks,
Ben
- The topic ‘How to loop for posts only with certain taxonomy?’ is closed to new replies.