title: How do I write a function for showing only one category?
body: <p>I want my wordpress page to show recent posts, with just one category.
  I'm new to PHP and wordpress, so please bear with me.</p>
  
  <pre><code>$categories = get_the_category();
  
  if ( ! empty( $categories ) ) {
      echo esc_html( $categories[0]-&gt;name );   
  }
  </code></pre>
  
  <p>When I past this code into my functions.php, the site crashes.</p>
  
  <p>You can see the site here: <a href="http://2016.sv.emil2518.mguro.sde.dk/skatersmag/" rel="nofollow noreferrer">http://2016.sv.emil2518.mguro.sde.dk/skatersmag/</a></p>