get_author_template

Retrieve path of author template in current or parent template.

Description

(string) get_author_template(); 

The hierarchy for this template looks like:

1. author-.php 2. author-.php 3. author.php

An example of this is:

1. author-john.php 2. author-1.php 3. author.php

The template hierarchy is filterable via the hook. The template path is filterable via the hook.

Returns (string)

Full path to author template file.


Usage

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

Defined (1)

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

/wp-includes/template.php  
  1. function get_author_template() { 
  2. $author = get_queried_object(); 
  3.  
  4. $templates = array(); 
  5.  
  6. if ( $author instanceof WP_User ) { 
  7. $templates[] = "author-{$author->user_nicename}.php"; 
  8. $templates[] = "author-{$author->ID}.php"; 
  9. $templates[] = 'author.php'; 
  10.  
  11. return get_query_template( 'author', $templates );