Advertisements

get_object_taxonomies

Definition:
function get_object_taxonomies($object, $output = 'names') {}

Return all of the taxonomy names that are of $object_type.
It appears that this function can be used to find all of the names inside of $wp_taxonomies global variable.

Parameters

  • array|string|object $object: Name of the type of taxonomy object, or an object (row from posts)
  • string $output: The type of output to return, either taxonomy ‘names’ or ‘objects’. ‘names’ is the default.

Return values

returns:The names of all taxonomy of $object_type.

Source code

function get_object_taxonomies($object, $output = 'names') {

	global $wp_taxonomies;



	if ( is_object($object) ) {

		if ( $object->post_type == 'attachment' )

			return get_attachment_taxonomies($object);

		$object = $object->post_type;

	}



	$object = (array) $object;



	$taxonomies = array();

	foreach ( (array) $wp_taxonomies as $tax_name => $tax_obj ) {

		if ( array_intersect($object, (array) $tax_obj->object_type) ) {

			if ( 'names' == $output )

				$taxonomies[] = $tax_name;

			else

				$taxonomies[ $tax_name ] = $tax_obj;

		}

	}



	return $taxonomies;

}

1510

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: