title: Wordpress: showing post categories inside loop
body: <p>I have a small problem with showing all post categories for each post inside my loop on custom archive page.</p>
  <p>This is How I try to show them:</p>
  <pre><code>$categories = get_the_terms( $post-&gt;ID, 'section' );
  foreach ((array) $categories as $category) {    
  echo  '&lt;span class=&quot;kat-label&quot;&gt;'. $category-&gt;name . '&lt;/span&gt;';
  }
  </code></pre>
  <p>As you can see there is a custom taxanomy &quot;section&quot; and I have there also custom post type called &quot;games&quot;.</p>
  <p>The problem is output. Some posts display correct cattegory names, some of them display none, and others show the same category name for example 7 times!</p>
  <p>I was trying to debug WP and I got something like that for results where 0 categories shows:</p>
  <pre><code>Warning: Attempt to read property &quot;name&quot; on bool in /home/....
  </code></pre>
  <p>And for others</p>
  <pre><code>Trying to access array offset on value of type null in /home/....../archive-games.php on line 238
  </code></pre>
  <p>The same code works perfect on single post whre categories are shown correctly.</p>
  <p>Any ideas how to fix that?</p>