title: How to show subcategory name of a post in wordpress?
body: <p>I have Main Category - Sub Category 1 - Sub Category 2 - Child Category .</p>
  
  <p>If i click the child category , using the following script i can sort the post.</p>
  
  <p><code>&lt;?php if (have_posts()) : $i = 0; while (have_posts()) : $i++; the_post(); ?&gt;</code></p>
  
  <p>To show the category name i use , </p>
  
  <p><code>$category = get_the_category();$category-&gt;cat_name;</code></p>
  
  <p>But i can't show the sub category and child category so please help me!.</p>