How to show all taxonomies within custom post type loop

I’m answering the <?php //echo tax names here ?>:

  1. In the loop, you can get the post terms using wp_get_post_terms():

    while ($articles->have_posts() ): $articles->the_post();
      $terms = wp_get_post_terms( get_the_ID(), 'topic', [ 'fields' => 'names' ] );
    
  2. Then you can do something like echo implode( ' ', $terms ); inside the <div> tag:

    <div class="masonry__item col-lg-3 col-md-6"
      data-masonry-filter="<?php echo implode( ' ', $terms ); ?>">
    

But are you very sure you want to use the term name and not slug?

If you want the term slug, then you’d use 'fields' => 'id=>slug' and not 'fields' => 'names'.