get_the_tag_list

Retrieve the tags for a post formatted as a string.

Description

(string|false|WP_Error) get_the_tag_list( (string) $before = '', (string) $sep = '', (string) $after = '', (int) $id = 0 ); 

Returns (string|false|WP_Error)

A list of tags on success, false if there are no terms, WP_Error on failure.

Parameters (4)

0. $before — Optional. (string) => ''
Before tags.
1. $sep — Optional. (string) => ''
Between tags.
2. $after — Optional. (string) => ''
After tags.
3. $id — Optional. (int)
Post ID. Defaults to the current post.

Usage

  1. if ( !function_exists( 'get_the_tag_list' ) ) { 
  2. require_once ABSPATH . WPINC . '/category-template.php'; 
  3.  
  4. // Optional. Before tags. 
  5. $before = ''; 
  6.  
  7. // Optional. Between tags. 
  8. $sep = ''; 
  9.  
  10. // Optional. After tags. 
  11. $after = ''; 
  12.  
  13. // Optional. Post ID. Defaults to the current post. 
  14. $id = -1; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = get_the_tag_list($before, $sep, $after, $id); 
  18.  

Defined (1)

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

/wp-includes/category-template.php  
  1. function get_the_tag_list( $before = '', $sep = '', $after = '', $id = 0 ) { 
  2.  
  3. /** 
  4. * Filters the tags list for a given post. 
  5. * @since 2.3.0 
  6. * @param string $tag_list List of tags. 
  7. * @param string $before String to use before tags. 
  8. * @param string $sep String to use between the tags. 
  9. * @param string $after String to use after tags. 
  10. * @param int $id Post ID. 
  11. */ 
  12. return apply_filters( 'the_tags', get_the_term_list( $id, 'post_tag', $before, $sep, $after ), $before, $sep, $after, $id );