How to show all taxonomies within custom post type loop

Question

I am trying to show all records for a particular custom post type and I want a list of all taxonomies in a dropdown.

Here is the query for the CPT:

<?php 
        $articles = new WP_Query(array(
        'posts_per_page' => -1,
        'post_type' => 'stories',
      ));
?>

And getting the terms

<?php
$terms = get_terms( array(
    'taxonomy' => 'topic',
    'hide_empty' => false,
) );
?>

Then the loop

<?php if ($articles->have_posts() ):
while ($articles->have_posts() ): $articles->the_post();
?>
// this is where I want to echo all taxonomy names
 <div class="masonry__item col-lg-3 col-md-6" data-masonry-filter="<?php //echo tax names here ?>">

<?php endwhile; ?>
 <?php wp_reset_postdata(); ?>
<?php endif; ?>
0
, , user10980228 2 years 2019-11-21T03:42:22-05:00 0 Answers 72 views 0

Leave an answer

Browse
Browse