WordPress:Template Tags/wp title

来自站长百科
Xxf3325讨论 | 贡献2008年7月13日 (日) 12:01的版本
跳转至: 导航、​ 搜索

描述

显示或者返回网页的标题。从2.5版本开始,可以定义一个分隔符字符串,可以指定这个分隔符字符串在网页标签之前或者之后显示。

只要标签是在主页的The Loop的外部,标签就可以用在模板内的任何位置,但是标签通常是用在<标签>元素内,作为网页的标头。

标签文本取决于查询:

单篇文章或者一个网页
文章(或者网页)的标题
按日期计算的存档:日期
(例如, "2006", "2006 – 一月")
类别:类别的名称
作者网页:用户的公用名称

用法

%%% <?php wp_title('sep', echo, 'seplocation'); ?> %%%


例子

默认用法

Displays the blog name (using bloginfo()) and the post title using defaults when accessing a single post page. If the blog name is "My WordPress Blog", and the title of the post is "Hello world!", then the example below will show the title as My WordPress Blog » Hello world!

显示博客名称(使用bloginfo()),访问只有一篇文章的网页的时候,文章标题使用默认设置。如果博客名是"我的WordPress 博客",文章标题是"世界,你好!",那么下面的例子会显示标题为我的 WordPress博客 » 世界,你好!

 <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title>
 <title><?php bloginfo('名称'); ?> <?php wp_标题(); ?></标题>

This example would the same do the same thing:

这个例子会执行同样的功能:

 <title><?php bloginfo('name'); ?> <?php wp_title('',true,''); ?></title>
 <title><?php bloginfo('名称'); ?> <?php wp_标题('',真的,''); ?></标题>

Using Separator

使用分隔符

Displays blog name (using bloginfo()) along with post title in the document's title tag, using "--" as the separator. This results in (when on a single post page) My WordPress Blog--Hello world!.

在文件的标题标签上显示博客名(使用bloginfo())和文章标题,使用"--"作为博客名和文章标题之间的分隔符。因此(当访问只有一篇文章的网页的时候),会出现标题我的 WordPress 博客—世界,你好!

 <title><?php bloginfo('name'); ?> <?php wp_title('--'); ?></title>
 <title><?php bloginfo('名称'); ?> <?php wp_表态('--'); ?></title>

This example would the same do the same thing:

这个例子执行同样的功能也是一样的:

 <title><?php bloginfo('name'); ?> <?php wp_title('--',true,''); ?></title>
 <title><?php bloginfo('名称'); ?> <?php wp_标题('--',真的,''); ?></标题>

Separator with Blog Name and Title Reversed

博客名和文章标题顺序颠倒时,之间的分隔符

This lets you reverse page title and blog name in the title tag from example above (Hello world!--My WordPress Blog) by removing the separator (using wp_title(' '), then tests if there is a post title (using if(wp_title(' ', false))), and displays the separator between it and bloginfo() if it does.

通过移动分隔符(使用wp_标题(' '),然后测试是否存在一个文章标题(使用 if(wp_标题(' ', 错误的))),可以颠倒上面的例子中的网页标题和博客名的排列顺序,在标题之间显示分隔符,如果显示了,再bloginfo()

For Wordpress 2.5 - latest

<title>
 <?php wp_title('--',true,'right'); ?>
 <?php bloginfo('name'); ?>
 </title>

For previous versions

<title>
 <?php wp_title(' '); ?>
 <?php if(wp_title(' ', false)) { echo '--'; } ?> 
 <?php bloginfo('name'); ?>
 </title>


对于WordPress2.5版本 – 最新的

<标题>
 <?php wp_标题('--',正确的,'right'); ?>
 <?php bloginfo('名称'); ?>
 </标题>

对于先前的版本

<标题>
 <?php wp_标题(' '); ?>
 <?php 如果(wp_标题(' ',错误的)) { echo '--'; } ?> 
 <?php bloginfo('名称'); ?>
 </标题>

Parameters

参数

sep
(string) Text to display before or after of the post title (i.e. the separator). By default (if sep is blank) then the &raquo; (») symbol will be placed before or after (specified by the seplocation) the post title.
sep
(string)文章标题之前或者之后显示的文本(例如分隔符)。默认情况下,(如果sep是空白的),那么就是&raquo; (»)符号会在文章标题之前或者之后显示(由seplocation规定)。
echo
(boolean) Echo the title (True) or return the title for use as a PHP string (False). Valid values:
echo
(boolean) Echo标题(正确的)或者返回标题作为一个PHP字符串使用(错误的)。有效的参数值:
  • 1 (True) - default
  • 0: (False)
  • 1 (正确的) – 默认的
  • 0: (错误的)
seplocation
(string) Introduced with Version 2.5, this parameter defines the location of where the sep string prints in relation to the title of the post. For all values except 'right', the sep value is placed in front of (to the left of) the post title. If the value of seplocation is 'right' then the sep string will be appended after the post title.
seplocation
(string)在2.5版本中引入,这个参数定义了与文章标题相关的sep字符串放置的位置。拥有除了'右边'外所有的参数值,sep参数值可以放在文章标题的前面(文章标题的左边)。如果seplocation的参数值是'右边的',那么sep字符串会附加在文章的后面。

Related

模板:Tag General Tags

模板:PHP Function Tag Footer

相关的

模板:标签总标签

模板:PHP 函数 标签 页底文字