get_tag_link

Retrieve the link to the tag.

Description

(string) get_tag_link( (int|object) $tag ); 

Returns (string)

Link on success, empty string if tag does not exist.

Parameters (1)

0. $tag (int|object)
Tag ID or object.

Usage

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

Defined (1)

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

/wp-includes/category-template.php  
  1. function get_tag_link( $tag ) { 
  2. if ( ! is_object( $tag ) ) 
  3. $tag = (int) $tag; 
  4.  
  5. $tag = get_term_link( $tag, 'post_tag' ); 
  6.  
  7. if ( is_wp_error( $tag ) ) 
  8. return ''; 
  9.  
  10. return $tag;