bp_get_object_terms( int|array $object_ids, string|array $taxonomies, array $args = array() )

Get taxonomy terms for a BuddyPress object.


Description Description

See also See also


Top ↑

Parameters Parameters

$object_ids

(Required) ID or IDs of objects.

$taxonomies

(Required) Name or names of taxonomies to match.

$args

(Optional) See wp_get_object_terms().

Default value: array()


Top ↑

Return Return

(array)


Top ↑

Source Source

File: bp-core/bp-core-taxonomy.php

function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
	// Different taxonomies must be stored on different sites.
	$taxonomy_site_map = array();
	foreach ( (array) $taxonomies as $taxonomy ) {
		$taxonomy_site_id = bp_get_taxonomy_term_site_id( $taxonomy );
		$taxonomy_site_map[ $taxonomy_site_id ][] = $taxonomy;
	}

	$retval = array();
	foreach ( $taxonomy_site_map as $taxonomy_site_id => $site_taxonomies ) {
		$switched = false;
		if ( $taxonomy_site_id !== get_current_blog_id() ) {
			switch_to_blog( $taxonomy_site_id );
			bp_register_taxonomies();
			$switched = true;
		}

		$site_terms = wp_get_object_terms( $object_ids, $site_taxonomies, $args );
		$retval     = array_merge( $retval, $site_terms );

		if ( $switched ) {
			restore_current_blog();
		}
	}

	return $retval;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.