bp_get_terms( array $args = array() )

Get taxonomy BP Terms from the database.


Parameters Parameters

$args

(array) (Optional) Array of arguments to query BP Terms. @see get_terms() for full description of arguments in case of a member type.

Default value: array()


Top ↑

Return Return

(array) The list of terms matching arguments.


Source Source

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

function bp_get_terms( $args = array() ) {
	$args = bp_parse_args(
		$args,
		array(
			'taxonomy'   => '',
			'number'     => '',
			'hide_empty' => false,
		),
		'get_terms'
	);

	if ( ! $args['taxonomy'] ) {
		return array();
	}

	$site_id = bp_get_taxonomy_term_site_id( $args['taxonomy'] );

	$switched = false;
	if ( $site_id !== get_current_blog_id() ) {
		switch_to_blog( $site_id );
		bp_register_taxonomies();
		$switched = true;
	}

	$terms = get_terms( $args );

	if ( $switched ) {
		restore_current_blog();
	}

	/**
	 * Filter here to modify the BP Terms found into the database.
	 *
	 * @since 7.0.0
	 *
	 * @param array $terms The list of terms matching arguments.
	 * @param array $args  Array of arguments used to query BP Terms.
	 */
	return apply_filters(
		'bp_get_terms',
		$terms,
		$args
	);
}


Top ↑

Changelog Changelog

Changelog
Version Description
7.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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