the_title()函数简介
the_title(string $before='',string $after='',bool $echo=true)显示或获得具有可选标记的当前文章标题。显示或检索具有可选标记的当前文章标题。
the_title()函数参数
$before,在标题前面的标记;$after,在标题后面的标记;
$echo:是否输出或者返回标题,默认为true表示输出,false表示返回。
the_title()函数延伸
此函数将显示或返回当前文章的未转义标题。这个标记只能在循环中使用,循环之外使用get_the_title获取文章的标题。如果该帖子是受保护的或私人的,这将在标题前注明“受保护:”或“私人:”。安全考虑
与the_content() 一样,the_title()的输出也是未转义的。这被认为是一个特性,而不是一个bug,请参见FAQ“为什么一些用户可以发布未经过滤的HTML?”.如果文章标题为“<script>alert("test");</script>”,则将在使用the_title()的地方将运行JavaStript代码。因此,不要编写允许不受信任的用户创建文章标题的代码。the_title()源代码
File: wp-includes/post-template.phpfunction 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; }} 转载请注明来源网址:青锋建站-http://www.sjzphp.com/cmsxitong/wordpressxt/the_title_1381.html