title: How to display category link in wordpress recent posts widget?
body: <p>I`m trying hard to display the category link for each post in Recent Posts widget, but nothing helps.. Every time i get an error</p>
  
  <pre><code>$category = get_the_category();
  </code></pre>
  
  <p>and then </p>
  
  <pre><code>&lt;?php if ( $show_category ) : ?&gt;
      &lt;a href="" class="category-link"&gt;&lt;?php  echo $category[0]-&gt;cat_name; ?&gt;&lt;/a&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>but it displays category in strange way: on the main page its always first category, for any post, when im reading the post - curent post category is shown for any post in widget. I really have no idea.</p>