WordPress: Template Tags/wp title:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == Displays or returns the title of the page. A separator string can be defined, and beginning with WordPress:Version 2.5, that separator can be designated to print b...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==


Displays or returns the title of the page.  A separator string can be defined, and beginning with [[WordPress:Version 2.5]], that separator can be designated to print before or after the title of the page.
Displays or returns the title of the page.  A separator string can be defined, and beginning with [[WordPress:Version 2.5]], that separator can be designated to print before or after the title of the page.
显示或者返回网页的标题。从[[WordPress:Version 2.5|2.5版本]]开始,可以定义一个分隔符字符串,可以指定这个分隔符字符串在网页标签之前或者之后显示。


This tag can be used anywhere within a template as long as it's outside [[WordPress:The Loop]] on the main page, though is typically used in the <tt>&lt;title&gt;</tt> element for the head of a page.
This tag can be used anywhere within a template as long as it's outside [[WordPress:The Loop]] on the main page, though is typically used in the <tt>&lt;title&gt;</tt> element for the head of a page.
只要标签是在主页的[[WordPress:The Loop|The Loop]]的外部,标签就可以用在模板内的任何位置,但是标签通常是用在<tt>&lt;标签&gt;</tt>元素内,作为网页的标头。


The title text depends on the query:
The title text depends on the query:
标签文本取决于查询:


; Single post or a [[WordPress:Pages|Page]]: the title of the post (or Page)
; Single post or a [[WordPress:Pages|Page]]: the title of the post (or Page)
;单篇文章或者一个[[WordPress:Pages|网页]]:文章(或者网页)的标题
; Date-based archive : the date (e.g., "2006", "2006 - January")
; Date-based archive : the date (e.g., "2006", "2006 - January")
; 按日期计算的存档:日期 : (例如, "2006", "2006 – 一月")
; Category : the name of the category
; Category : the name of the category
;类别:类别的名称
; Author page : the public name of the user
; Author page : the public name of the user
;作者网页:用户的公用名称
== Usage ==


== Usage ==
== 用法 ==


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


== Examples ==
== Examples ==


=== Default Usage ===
=== Default Usage ===
== 例子 ==
=== 默认用法===


Displays the blog name (using [[WordPress:Template Tags/bloginfo|<tt>bloginfo()</tt>]]) 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  &raquo; Hello world!
Displays the blog name (using [[WordPress:Template Tags/bloginfo|<tt>bloginfo()</tt>]]) 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  &raquo; Hello world!
显示博客名称(使用[[WordPress:Template Tags/bloginfo|<tt>bloginfo()</tt>]]),访问只有一篇文章的网页的时候,文章标题使用默认设置。如果博客名是"我的WordPress 博客",文章标题是"世界,你好!",那么下面的例子会显示标题为'''我的 WordPress博客  &raquo; 世界,你好!
<pre> <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title></pre>
<pre> <title><?php bloginfo('name'); ?> <?php wp_title(); ?></title></pre>
<pre> <title><?php bloginfo('名称'); ?> <?php wp_标题(); ?></标题></pre>


This example would the same do the same thing:
This example would the same do the same thing:
这个例子会执行同样的功能:
<pre> <title><?php bloginfo('name'); ?> <?php wp_title('',true,''); ?></title></pre>
<pre> <title><?php bloginfo('name'); ?> <?php wp_title('',true,''); ?></title></pre>
<pre> <title><?php bloginfo('名称'); ?> <?php wp_标题('',真的,''); ?></标题></pre>


=== Using Separator ===
=== Using Separator ===
=== 使用分隔符 ===


Displays blog name (using [[WordPress:Template Tags/bloginfo|<tt>bloginfo()</tt>]]) 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!'''.
Displays blog name (using [[WordPress:Template Tags/bloginfo|<tt>bloginfo()</tt>]]) 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!'''.
在文件的标题标签上显示博客名(使用[[WordPress:Template Tags/bloginfo|<tt>bloginfo()</tt>]])和文章标题,使用"--"作为博客名和文章标题之间的分隔符。因此(当访问只有一篇文章的网页的时候),会出现标题'''我的 WordPress 博客—世界,你好!'''


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


This example would the same do the same thing:
This example would the same do the same thing:
这个例子执行同样的功能也是一样的:
<pre> <title><?php bloginfo('name'); ?> <?php wp_title('--',true,''); ?></title></pre>
<pre> <title><?php bloginfo('name'); ?> <?php wp_title('--',true,''); ?></title></pre>
 
<pre> <title><?php bloginfo('名称'); ?> <?php wp_标题('--',真的,''); ?></标题></pre>
 
=== Separator with Blog Name and Title Reversed ===
=== 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 <tt>wp_title(' ')</tt>, then tests if there is a post title (using <tt>if(wp_title(' ', false))</tt>), and displays the separator between it and <tt>bloginfo()</tt> if it does.
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 <tt>wp_title(' ')</tt>, then tests if there is a post title (using <tt>if(wp_title(' ', false))</tt>), and displays the separator between it and <tt>bloginfo()</tt> if it does.
通过移动分隔符(使用<tt>wp_标题(' ')</tt>,然后测试是否存在一个文章标题(使用 <tt>if(wp_标题(' ', 错误的))</tt>),可以颠倒上面的例子中的网页标题和博客名的排列顺序,在标题之间显示分隔符,如果显示了,再<tt>bloginfo()</tt>。


'''For Wordpress 2.5 - latest'''
'''For Wordpress 2.5 - latest'''
第51行: 第101行:
  <?php bloginfo('name'); ?>
  <?php bloginfo('name'); ?>
  </title></pre>
  </title></pre>
'''对于WordPress2.5版本 – 最新的'''
<pre><标题>
<?php wp_标题('--',正确的,'right'); ?>
<?php bloginfo('名称'); ?>
</标题></pre>
'''对于先前的版本'''
<pre><标题>
<?php wp_标题(' '); ?>
<?php 如果(wp_标题(' ',错误的)) { echo '--'; } ?>
<?php bloginfo('名称'); ?>
</标题></pre>


== Parameters ==
== 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 &amp;raquo; (&raquo;) symbol will be placed before or after (specified by the '''seplocation''') the post title.   
; sep : (''string'') Text to display before or after of the post title (i.e. the separator).  By default (if sep is blank) then the &amp;raquo; (&raquo;) symbol will be placed before or after (specified by the '''seplocation''') the post title.   
; sep : (''string'')文章标题之前或者之后显示的文本(例如分隔符)。默认情况下,(如果sep是空白的),那么就是&amp;raquo; (&raquo;)符号会在文章标题之前或者之后显示(由'''seplocation'''规定)。
; echo : (boolean) Echo the title (True) or return the title for use as a PHP string (False).  Valid values:
; echo : (boolean) Echo the title (True) or return the title for use as a PHP string (False).  Valid values:
; echo : (boolean) Echo标题(正确的)或者返回标题作为一个PHP字符串使用(错误的)。有效的参数值:
:*<tt>1</tt> (True) - default  
:*<tt>1</tt> (True) - default  
:*<tt>0</tt>: (False)
:*<tt>0</tt>: (False)
:*<tt>1</tt> (正确的) – 默认的
:*<tt>0</tt>: (错误的)
; 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'') 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 ==
== Related ==
第65行: 第144行:


{{PHP Function Tag Footer}}
{{PHP Function Tag Footer}}
== 相关的==
{{标签总标签}}
{{PHP 函数 标签 页底文字}}

2008年7月3日 (四) 11:21的版本

Description

描述

Displays or returns the title of the page. A separator string can be defined, and beginning with WordPress:Version 2.5, that separator can be designated to print before or after the title of the page.

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

This tag can be used anywhere within a template as long as it's outside WordPress:The Loop on the main page, though is typically used in the <title> element for the head of a page.

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

The title text depends on the query:

标签文本取决于查询:

Single post or a Page
the title of the post (or Page)

;单篇文章或者一个网页:文章(或者网页)的标题

Date-based archive
the date (e.g., "2006", "2006 - January")
按日期计算的存档:日期
(例如, "2006", "2006 – 一月")
Category
the name of the category

;类别:类别的名称

Author page
the public name of the user

;作者网页:用户的公用名称

Usage

用法

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

%%% <?php wp_标题('sep', echo, 'seplocation'); ?> %%%

Examples

Default Usage

例子

默认用法

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 函数 标签 页底文字