get_the_tags

Retrieve the tags for a post.

Description

(array|false|WP_Error) get_the_tags( (int) $id = 0 ); 

Returns (array|false|WP_Error)

Array of tag objects on success, false on failure.

Parameters (1)

0. $id — Optional. (int)
Post ID.

Usage

  1. if ( !function_exists( 'get_the_tags' ) ) { 
  2. require_once ABSPATH . WPINC . '/category-template.php'; 
  3.  
  4. // Post ID. 
  5. $id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_the_tags($id); 
  9.  

Defined (1)

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

/wp-includes/category-template.php  
  1. function get_the_tags( $id = 0 ) { 
  2.  
  3. /** 
  4. * Filters the array of tags for the given post. 
  5. * @since 2.3.0 
  6. * @see get_the_terms() 
  7. * @param array $terms An array of tags for the given post. 
  8. */ 
  9. return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );