Function Reference: geodir_get_category_parents
Summary
Get the parent categories of current id.
Package
GeoDirectory
Parameters
- $id
- (int) (required) Category id.
- Default: None
- $taxomony
- (string) (required) Category taxonomy of post type.
- Default: None
- $visited
- (array) (required) Array of category ids already included.
- Default: None
- $parents
- (array) (required) Array of category ids.
- Default: None
Return Values
- (array)
- Category ids.
Change Log
Since: 1.5.7
Source File
geodir_get_category_parents() is located in geodirectory-functions/helper_functions.php [Line: 411]
Source Code
function geodir_get_category_parents($id, $taxomony, $visited = array(), $parents = array()) { $parent = get_term($id, $taxomony); if (is_wp_error($parent)) { return $parents; } if (isset($parent->parent) && $parent->parent && ($parent->parent != $parent->term_id) && !in_array($parent->parent, $visited)) { $visited[] = $parent->parent; $parents[] = $parent->parent; $parents = geodir_get_category_parents($parent->parent, $taxomony, $visited, $parents); } return $parents; }