single_tag_title()获取当前标签页面的标题

目录

描述

Displays or returns the tag title for the current archive page.

single_tag_title() 描述

用法

 <?php single_tag_title$prefix$display ); ?> 

Default Usage

 <?php single_tag_title(); ?> 

single_tag_title() 用法

参数

$prefix

(string) (可选) Text to output before the title.

默认值: None

Note: The $prefix argument is currently ignored if the $display argument is false.
See http://core.trac.wordpress.org/ticket/16632

$display

(boolean) (可选) Display the title (TRUE), or return the title to be used in PHP (FALSE).

默认值: TRUE

single_tag_title() 参数

示例

This example displays the text "Currently browsing " followed by the tag title.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<p><?php single_tag_title('Currently browsing '); ?>.</p>
Currently browsing WordPress.

This example assigns the current tag title to the variable $current_tag for use in PHP.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
<?php $current_tag = single_tag_title("", false); ?>

single_tag_title() 示例

历史

single_tag_title() 历史

源文件

single_tag_title() 函数的代码位于 wp-includes/general-template.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Display or retrieve page title for tag post archive.
 *
 * Useful for tag template files for displaying the tag page title. It has less
 * overhead than {@link wp_title()}, because of its limited implementation.
 *
 * It does not support placing the separator after the title, but by leaving the
 * prefix parameter empty, you can set the title separator manually. 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.
 *
 * @since 2.3.0
 *
 * @param string $prefix  Optional. What to display before the title.
 * @param bool   $display Optional, default is true. Whether to display or retrieve title.
 * @return string|void Title when retrieving.
 */
function single_tag_title( $prefix = '', $display = true ) {
	return single_term_title( $prefix, $display );
}

single_tag_title() 源文件

相关