bp_get_object_terms

Get taxonomy terms for a BuddyPress object.

Description

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

Returns (array)

Parameters (3)

0. $object_ids (int|array)
ID or IDs of objects.
1. $taxonomies (string|array)
Name or names of taxonomies to match.
2. $args — Optional. (array) => array()
The args.

Usage

  1. if ( !function_exists( 'bp_get_object_terms' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-taxonomy.php'; 
  3.  
  4. // ID or IDs of objects. 
  5. $object_ids = null; 
  6.  
  7. // Name or names of taxonomies to match. 
  8. $taxonomies = null; 
  9.  
  10. // The args. 
  11. $args = array(); 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_get_object_terms($object_ids, $taxonomies, $args); 
  15.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-taxonomy.php  
  1. function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) { 
  2. // Different taxonomies must be stored on different sites. 
  3. $taxonomy_site_map = array(); 
  4. foreach ( (array) $taxonomies as $taxonomy ) { 
  5. $taxonomy_site_id = bp_get_taxonomy_term_site_id( $taxonomy ); 
  6. $taxonomy_site_map[ $taxonomy_site_id ][] = $taxonomy; 
  7.  
  8. $retval = array(); 
  9. foreach ( $taxonomy_site_map as $taxonomy_site_id => $site_taxonomies ) { 
  10. $switched = false; 
  11. if ( $taxonomy_site_id !== get_current_blog_id() ) { 
  12. switch_to_blog( $taxonomy_site_id ); 
  13. $switched = true; 
  14.  
  15. $site_terms = wp_get_object_terms( $object_ids, $site_taxonomies, $args ); 
  16. $retval = array_merge( $retval, $site_terms ); 
  17.  
  18. if ( $switched ) { 
  19.  
  20. return $retval;