the_terms

Display the terms in a list.

Description

(false|void) the_terms( (int) $id, (string) $taxonomy, (string) $before = '', (string) $sep = ', ', (string) $after = '' ); 

Returns (false|void)

False on WordPress error.

Parameters (5)

0. $id (int)
Post ID.
1. $taxonomy (string)
Taxonomy name.
2. $before — Optional. (string) => ''
Before list.
3. $sep — Optional. (string) => ', '
Separate items using this.
4. $after — Optional. (string) => ''
After list.

Usage

  1. if ( !function_exists( 'the_terms' ) ) { 
  2. require_once ABSPATH . WPINC . '/category-template.php'; 
  3.  
  4. // Post ID. 
  5. $id = -1; 
  6.  
  7. // Taxonomy name. 
  8. $taxonomy = ''; 
  9.  
  10. // Optional. Before list. 
  11. $before = ''; 
  12.  
  13. // Optional. Separate items using this. 
  14. $sep = ', '; 
  15.  
  16. // Optional. After list. 
  17. $after = ''; 
  18.  
  19. // NOTICE! Understand what this does before running. 
  20. $result = the_terms($id, $taxonomy, $before, $sep, $after); 
  21.  

Defined (1)

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

/wp-includes/category-template.php  
  1. function the_terms( $id, $taxonomy, $before = '', $sep = ', ', $after = '' ) { 
  2. $term_list = get_the_term_list( $id, $taxonomy, $before, $sep, $after ); 
  3.  
  4. if ( is_wp_error( $term_list ) ) 
  5. return false; 
  6.  
  7. /** 
  8. * Filters the list of terms to display. 
  9. * @since 2.9.0 
  10. * @param array $term_list List of terms to display. 
  11. * @param string $taxonomy The taxonomy name. 
  12. * @param string $before String to use before the terms. 
  13. * @param string $sep String to use between the terms. 
  14. * @param string $after String to use after the terms. 
  15. */ 
  16. echo apply_filters( 'the_terms', $term_list, $taxonomy, $before, $sep, $after );