bbp_get_topic_tag_list( int $topic_id, array $args = '' )

Return the tags of a topic

Description

Parameters

$topic_id

(int) (Optional) Topic id

$args

(array) (Optional) This function supports these arguments: - before: Before the tag list - sep: Tag separator - after: After the tag list

Default value: ''

Return

(string) Tag list of the topic

Source

File: bp-forums/topics/template.php

	function bbp_get_topic_tag_list( $topic_id = 0, $args = '' ) {

		// Bail if topic-tags are off
		if ( ! bbp_allow_topic_tags() )
			return;

		// Parse arguments against default values
		$r = bbp_parse_args( $args, array(
			'before' => '<div class="bbp-topic-tags"><p>' . esc_html__( 'Tagged:', 'buddyboss' ) . '&nbsp;',
			'sep'    => ', ',
			'after'  => '</p></div>'
		), 'get_topic_tag_list' );

		$topic_id = bbp_get_topic_id( $topic_id );

		// Topic is spammed, so display pre-spam terms
		if ( bbp_is_topic_spam( $topic_id ) ) {

			// Get pre-spam terms
			$terms = get_post_meta( $topic_id, '_bbp_spam_topic_tags', true );

			// If terms exist, explode them and compile the return value
			if ( !empty( $terms ) ) {
				$terms  = implode( $r['sep'], $terms );
				$retval = $r['before'] . $terms . $r['after'];

			// No terms so return emty string
			} else {
				$retval = '';
			}

		// Topic is not spam so display a clickable term list
		} else {
			$retval = get_the_term_list( $topic_id, bbp_get_topic_tag_tax_id(), $r['before'], $r['sep'], $r['after'] );
		}

		return $retval;
	}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.