bbp_get_topic_tag_names

Get topic tags for a specific topic ID.

Description

(string) bbp_get_topic_tag_names( (int) $topic_id = 0, (string) $sep = ', ' ); 

Returns (string)

Parameters (2)

0. $topic_id — Optional. (int)
The topic id.
1. $sep — Optional. (string) => ', '
The sep.

Usage

  1. if ( !function_exists( 'bbp_get_topic_tag_names' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/topics/functions.php'; 
  3.  
  4. // The topic id. 
  5. $topic_id = -1; 
  6.  
  7. // The sep. 
  8. $sep = ', '; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_get_topic_tag_names($topic_id, $sep); 
  12.  

Defined (1)

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

/includes/topics/functions.php  
  1. function bbp_get_topic_tag_names( $topic_id = 0, $sep = ', ' ) { 
  2. $topic_id = bbp_get_topic_id( $topic_id ); 
  3. $topic_tags = array_filter( (array) get_the_terms( $topic_id, bbp_get_topic_tag_tax_id() ) ); 
  4. $terms = array(); 
  5. foreach ( $topic_tags as $term ) { 
  6. $terms[] = $term->name; 
  7. $terms = !empty( $terms ) ? implode( $sep, $terms ) : ''; 
  8.  
  9. return apply_filters( 'bbp_get_topic_tags', $terms, $topic_id );