get_author_template() - WordPress 函数参考中文文档

返回介绍

get_author_template()

发布于 2017-09-10 字数1630 浏览 805 评论 0

get_author_template()

Retrieve path of author template in current or parent template.


描述

The hierarchy for this template looks like:

  1. author-{nicename}.php
  2. author-{id}.php
  3. author.php

An example of this is:

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

The template hierarchy and template path are filterable via the ‘$type_template_hierarchy’ and ‘$type_template’ dynamic hooks, where $type is ‘author’.


返回值

(string) Full path to author template file.


源代码

File: wp-includes/template.php

function get_author_template() {
	$author = get_queried_object();

	$templates = array();

	if ( $author instanceof WP_User ) {
		$templates[] = "author-{$author->user_nicename}.php";
		$templates[] = "author-{$author->ID}.php";
	}
	$templates[] = 'author.php';

	return get_query_template( 'author', $templates );
}

更新日志

Version 描述
1.5.0 Introduced.

相关函数

Uses

  • wp-includes/query.php:
    get_queried_object()
  • wp-includes/template.php:
    get_query_template()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!