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

描述:

显示当前文章的标题

用法:

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

参数:

$before

(string) (可选) 标题之前显示的文本

默认值: None

$after

(string) (可选) 标题之后显示的文本

默认值: None

$echo

(Boolean) (可选) 显示标题(TRUE)或将其返回以在PHP中使用(FALSE)。

默认值: TRUE

源文件:

/**
 * 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;
}