Function Reference: geodir_add_parent_terms

Summary

Add the parent terms in current terms.

Package

GeoDirectory

Parameters

$term_ids
(int|array) (required) Term id or Terms array.

Default: None
$taxomony
(string) (required) Category taxonomy of post type.

Default: None

Return Values

(array)
  • Modified term ids.

Change Log

Since: 1.5.7

Source File

geodir_add_parent_terms() is located in geodirectory-functions/helper_functions.php [Line: 380]

Source Code

function geodir_add_parent_terms($term_ids, $taxomony) {	
	if (is_int($term_ids)) {
		$term_ids = array($term_ids);
	}
	
	$parent_terms = array();
	
	foreach ($term_ids as $term_id) {
		$parent_terms[] = $term_id;
		$term_parents = geodir_get_category_parents($term_id, $taxomony, $parent_terms);
		
		if (!empty($term_parents)) {
			$parent_terms = array_merge($parent_terms, $term_parents);
		}
	}

	return $parent_terms;
}