Posted By

visualadvance on 01/03/10


Tagged

php wordpress category child Parent


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

maxvee8


Wordpress: Get first category name only


 / Published in: PHP
 

This is useful if a post is in a child category and you only want to list the immediate category. Unlike get_categories which will show the parent categories as well.

  1. <?php
  2. $category = get_the_category();
  3. echo $category[0]->cat_name;
  4. ?>

Report this snippet  

You need to login to post a comment.