Wordpress Get Root Category


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.