title: How to display list items with each tag of custom post-types as data-filter and text?
body: <p>as a newbie in php I am having trouble achieving an as I guess quite simple thing.</p>
  
  <p>I got this code so far (in a php template file):</p>
  
  <pre><code>&lt;?php                                    
      //Define my custom post type name in the arguments                           
      $args = array('post_type' =&gt; 'reference-document');          
  ?&gt; 
  
  &lt;ul&gt; 
      &lt;li&gt;&lt;a href="#" data-filter=".2013"&gt;2013&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#" data-filter=".2014"&gt;2014&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="#" data-filter=".2015"&gt;2015&lt;/a&gt;&lt;/li&gt;      
  &lt;/ul&gt;
  </code></pre>
  
  <p>In my custom post-type 'reference-document' I have a list of available tags with the years 2013,2014,2015</p>
  
  <p>Now, actually, my above code is working but I wish to output the li list depending on how many years ever the user might enter as tags in the post-type. (so eventually also 2016,2017…)</p>
  
  <p>So I guess I need to create the list with a php loop or whatever taking the available tags of my post-type as arguments. So far I have tried something like:</p>
  
  <pre><code>&lt;?php                           
      $tags = get_the_tags();   
      foreach ( $tags as $tag ) {
          echo '&lt;li&gt;&lt;a href="#" data-filter=".'.esc_attr($tag-&gt;tag_name).'"&gt;'.esc_attr($tag-&gt;tag_name).'&lt;/a&gt;&lt;/li&gt;';
      }
  ?&gt;
  </code></pre>
  
  <p>to get the same output as I had achieved “manually”. But this throws errors and I am quite stuck here. Anyone how can give me the right code?</p>
  
  <p>Please do not forward me to the official standard WP documentations as I tried to understand them but didn’t succeed. I need concrete code. Then I might understand how it is working. Thanks so much in advance!</p>
  
  <p><strong>EDIT</strong>
  When I add the if statement in my code as:</p>
  
  <pre><code>&lt;?php                           
      $tags = get_the_tags(); 
      if(!empty($tags)) {  
          foreach ( $tags as $tag ) {
              echo '&lt;li&gt;&lt;a href="#" data-filter=".'.esc_attr($tag-&gt;tag_name).'"&gt;'.esc_attr($tag-&gt;tag_name).'&lt;/a&gt;&lt;/li&gt;';
          }
      }
  ?&gt;
  </code></pre>
  
  <p>in fact there are no more errors but nothing happens also. Which I guess means the 'tags' array is empty. But why? There are tags assigned in my custom post-type. As I said I am really new here so I guess my code contains some semantic illness. Please check!</p>