Skip to content

Instantly share code, notes, and snippets.

@not-only-code
Last active December 14, 2015 01:09
Show Gist options
  • Save not-only-code/5003753 to your computer and use it in GitHub Desktop.
Save not-only-code/5003753 to your computer and use it in GitHub Desktop.
return only the top level terms of the object/s
/**
* get top level object terms
* @package default
* @version 1.0
**/
function _get_object_parent_terms ($object, $taxonomies, $args = array()) {
$object_terms = wp_get_object_terms($object, $taxonomies, $args);
$output = array();
foreach ($object_terms as $object_term)
if ($object_term->parent == 0)
array_push($output, $object_term);
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment