the_title()显示当前文章的标题

目录

描述

Displays or returns the title of the current post. This tag may only be used within The Loop, to get the title of a post outside of the loop use get_the_title. If the post is protected or private, this will be noted by the words "Protected: " or "Private: " prepended to the title.

the_title() 描述

用法

 <?php the_title$before$after$echo ); ?> 

the_title() 用法

参数

$before

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

默认值: None

$after

(string) (可选) Text to place after the title.

默认值: None

$echo

(Boolean) (可选) Display the title (TRUE) or return it for use in PHP (FALSE).

默认值: TRUE

the_title() 参数

注意

历史

添加于 版本: 0.71

the_title() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Display or retrieve the current post title with optional content.
 *
 * @since 0.71
 *
 * @param string $before Optional. Content to prepend to the title.
 * @param string $after  Optional. Content to append to the title.
 * @param bool   $echo   Optional, default to true.Whether to display or return.
 * @return string|void String if $echo parameter is false.
 */
function the_title( $before = '', $after = '', $echo = true ) {
	$title = get_the_title();

	if ( strlen($title) == 0 )
		return;

	$title = $before . $title . $after;

	if ( $echo )
		echo $title;
	else
		return $title;
}

the_title() 源文件

相关