Posted By

widescape on 01/24/11


Tagged

wordpress category categories root


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kirichev


Wordpress Get Root Category


 / Published in: PHP
 

  1. function get_root_category($category)
  2. {
  3. $category = is_object($category) ? $category : get_category($category);
  4. while ($category->parent > 0) $category = get_category($category->parent);
  5. return $category;
  6. }

Report this snippet  

You need to login to post a comment.