get_the_author_link

Retrieve either author's link or author's name.

Description

(string|null) get_the_author_link(); 

If the author has a home page set, return an HTML link, otherwise just return the author's name.

Returns (string|null)

An HTML link if the author's url exist in user meta, else the result of get_the_author().


Usage

  1. if ( !function_exists( 'get_the_author_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/author-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = get_the_author_link(); 
  7.  

Defined (1)

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

/wp-includes/author-template.php  
  1. function get_the_author_link() { 
  2. if ( get_the_author_meta('url') ) { 
  3. return sprintf( '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',  
  4. /** translators: %s: author's display name */ 
  5. esc_attr( sprintf( __( 'Visit %s’s website' ), get_the_author() ) ),  
  6. ); 
  7. } else { 
  8. return get_the_author();