title: Don't echo the same parent category name inside loop
body: <p>I have some code, which show me:</p>
  <p>-- Parent custom category name</p>
  <p>--- Child custom category name</p>
  <p>---- Custom post name</p>
  <p>There are this code:</p>
  <pre><code>    &lt;?php
      $post_type = 'zakony';
      $taxonomies = get_object_taxonomies( array( 'post_type' =&gt; $post_type ) );
       
      foreach( $taxonomies as $taxonomy ) :
          $arg = array('hierarchical'  =&gt; false, 'orderby' =&gt; 'title', 'order' =&gt; 'DESC');
          $terms = get_terms(&quot;all&quot;, $arg);
      
          foreach( $terms as $term ) :
  
             if ( ! empty( $terms ) ) :
             $term = array_pop( $terms );
             $parent_term = ( $term-&gt;parent ? get_term( $term-&gt;parent, 'all' ) : $term );
             echo '&lt;strong&gt;'.$parent_term-&gt;name.'&lt;/strong&gt;&lt;br&gt;';      
             endif; ?&gt;
            &lt;strong class=&quot;child_cat&quot;&gt;&lt;?php echo $term-&gt;name; ?&gt;&lt;/strong&gt;
          &lt;?php
          $args = array(MY ARGS GOES HERE);
          $posts = new WP_Query($args);
          if( $posts-&gt;have_posts() ): while( $posts-&gt;have_posts() ) : $posts-&gt;the_post(); ?&gt;
          &lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; class=&quot;child_url&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
          &lt;?php endwhile; endif; ?&gt;
      &lt;?php endforeach;
  endforeach; ?&gt;
  </code></pre>
  <p>And its work fine and looks like:
  <a href="https://i.stack.imgur.com/8vzg9.png" rel="nofollow noreferrer">click here to see</a></p>
  <p>But how I can show the parent custom category name only once if its same?
  I mean, i`d like to show the unique parent custom category name, and dont show it more than once if it same! Could you help me please?</p>