函数文档

single_tag_title()

💡 云策文档标注

概述

single_tag_title() 函数用于在标签文章归档页面显示或检索页面标题,适用于标签模板文件。该函数是 single_term_title() 的包装器,前缀参数不会自动添加空格。

关键要点

  • 功能:显示或检索标签归档页面的标题,常用于标签模板中。
  • 参数:$prefix(可选,前缀字符串,需手动添加空格)和 $display(可选,布尔值,控制显示或检索,默认 true)。
  • 返回值:检索时返回字符串,显示时无返回值。
  • 实现:内部调用 single_term_title() 函数。
  • 相关函数:与 single_term_title() 和 get_the_archive_title() 关联。

代码示例

// 示例1:显示“Currently browsing ”后跟标签标题
single_tag_title('Currently browsing ');

// 示例2:将当前标签标题赋值给变量 $current_tag
$current_tag = single_tag_title('', false);

注意事项

  • 前缀参数 $prefix 不会自动添加空格,如需空格应在参数值末尾手动添加。
  • 该函数自 WordPress 2.3.0 版本引入。

📄 原文内容

Displays or retrieves page title for tag post archive.

Description

Useful for tag template files for displaying the tag page title. The prefix does not automatically place a space between the prefix, so if there should be a space, the parameter value will need to have it at the end.

Parameters

$prefixstringoptional
What to display before the title.
$displaybooloptional
Whether to display or retrieve title.

Default:true

Return

string|void Title when retrieving.

Source

function single_tag_title( $prefix = '', $display = true ) {
	return single_term_title( $prefix, $display );
}

Changelog

Version Description
2.3.0 Introduced.

User Contributed Notes