title: WordPress Individual Category Name within wp_query
body: <p>Using the below wp_query to pull in the latest post from three different categories. As part of this I want to display the category name appropriate for each article, which <code>the_category();</code> does achieve, however it places a <code>&lt;a&gt;</code> and <code>&lt;li&gt;</code> tags around the name. I'm wanting to simply get the name of the category?</p>
  
  <pre><code>&lt;?php
  $categories = get_categories();
  foreach ($categories as $category)
  {
  
  }
  $args = array(
      'cat' =&gt; 'article,fitness,recipe',
      'posts_per_page' =&gt; '3',
  );
  
  $query = new WP_Query($args);
  
  if ($query-&gt;have_posts())
  {
  
      ?&gt;
      &lt;?php
      while ($query-&gt;have_posts())
      {
          $query-&gt;the_post();
          ?&gt;
          &lt;article id="post-&lt;?php the_ID(); ?&gt;" class="col"&gt;
              &lt;h5&gt;&lt;?php echo the_category(); ?&gt;&lt;/h5&gt;
          &lt;/article&gt;
  
      &lt;?php } // end while  ?&gt; 
  &lt;?php
  } // end if
  wp_reset_postdata();
  ?&gt;
  </code></pre>