WordPress: Template Tags/get the tag list:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == Generates a HTML string of the tags associated with the current post. The name of each tag will be linked to the relevant 'tag' page. You can tell the function to put a...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==


Generates a HTML string of the tags associated with the current post. The name of each tag will be linked to the relevant 'tag' page. You can tell the function to put a string before and after all the tags, and in between each tag. This tag must be used inside 'The Loop'.
Generates a HTML string of the tags associated with the current post. The name of each tag will be linked to the relevant 'tag' page. You can tell the function to put a string before and after all the tags, and in between each tag. This tag must be used inside 'The Loop'.
创建与当前文章相关的标签的HTML字符串。每个标签的名称会链接到相关的'标签'网页。你可以命令函数在所有的标签前后放置一个字符串,而且在每个标签之间也放置一个字符串。必须在'The Loop'内使用这个标签。


== Usage ==
== Usage ==
== 用法 ==


This function does not display anything - if you want to put it straight onto the page, you should use <code>echo (get_the_tag_list())</code>. Alternatively, you can assign it to a variable for further use by using <code>$foo = get_the_tag_list()</code>.
This function does not display anything - if you want to put it straight onto the page, you should use <code>echo (get_the_tag_list())</code>. Alternatively, you can assign it to a variable for further use by using <code>$foo = get_the_tag_list()</code>.
这个函数不显示任何内容 – 如果你想要直接地将这个函数放到网页上,你应该使用<code>echo (get_the_tag_list())</code>。另外,你可以通过使用<code>$foo = get_the_tag_list()</code>,将这个函数递交给一个变数,以便以后使用。


The variables are all optional, and should be placed in the order 'before', 'separator', 'after'. You can use HTML inside each of the fields.
The variables are all optional, and should be placed in the order 'before', 'separator', 'after'. You can use HTML inside each of the fields.
变数都是可选择的,而且应该以'前', '分隔符', '后'的顺序排列。你可以在每个区内使用HTML。


== Example ==
== Example ==
== 例子 ==


=== A Basic Example ===
=== A Basic Example ===
===一个基本的例子===


This outputs the list of tags inside a paragraph, with tags separated by commas.
This outputs the list of tags inside a paragraph, with tags separated by commas.
这在一个段落中产生了一列标签,标签是用逗号分开的。
<pre>
<?php
echo get_the_tag_list('<p>Tags: ',', ','</p>');
?>
</pre>


<pre>
<pre>
第22行: 第44行:


This would return something like.
This would return something like.
这会返回:
<pre>
<p>
Tags:
<a href="tag1">Tag 1</a>,
<a href="tag2">Tag 2</a>, ...
</p>
</pre>


<pre>
<pre>
<p>
<p>
Tags:  
标签:  
<a href="tag1">Tag 1</a>,  
<a href="tag1">Tag 1</a>,  
<a href="tag2">Tag 2</a>, ...  
<a href="tag2">Tag 2</a>, ...  
第32行: 第62行:


=== A Slightly More Complex Example ===
=== A Slightly More Complex Example ===
=== A Slightly More Complex Example ===
=== 一个稍微复杂的例子 ===


This checks if the post has any tags, and if there are, outputs them to a standard unordered list.
This checks if the post has any tags, and if there are, outputs them to a standard unordered list.
这个例子检查文章是否含有任何标签,如果文章含有标签,将标签放到一个标准的无序列表上。
<pre>
<?php
if(get_the_tag_list()) {
get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
}
?>
</pre>
<pre>
<pre>
<?php
<?php
第43行: 第90行:


This will return something in the form:
This will return something in the form:
这会返回以这个形式出现的内容;
<pre>
<ul>
<li><a href="tag1">Tag 1</a></li>
<li><a href="tag2">Tag 2</a></li>
...
</ul>
</pre>
<pre>
<pre>
<ul>
<ul>
第52行: 第109行:


You can add classes and styles with CSS, as necessary./
You can add classes and styles with CSS, as necessary./
 
如果需要的话,你可以添加CSS的class和样式。/


{{Tag Tag Tags}}
{{Tag Tag Tags}}
第58行: 第115行:
{{PHP Function Tag Footer}}
{{PHP Function Tag Footer}}


{{Stub}}
{{标签标签 标签}}
{{PHP函数标签页底文字}}
{{Stub}}
{{Stub}}

2008年7月10日 (四) 16:24的版本

Description

描述

Generates a HTML string of the tags associated with the current post. The name of each tag will be linked to the relevant 'tag' page. You can tell the function to put a string before and after all the tags, and in between each tag. This tag must be used inside 'The Loop'.

创建与当前文章相关的标签的HTML字符串。每个标签的名称会链接到相关的'标签'网页。你可以命令函数在所有的标签前后放置一个字符串,而且在每个标签之间也放置一个字符串。必须在'The Loop'内使用这个标签。

Usage

用法

This function does not display anything - if you want to put it straight onto the page, you should use echo (get_the_tag_list()). Alternatively, you can assign it to a variable for further use by using $foo = get_the_tag_list().

这个函数不显示任何内容 – 如果你想要直接地将这个函数放到网页上,你应该使用echo (get_the_tag_list())。另外,你可以通过使用$foo = get_the_tag_list(),将这个函数递交给一个变数,以便以后使用。

The variables are all optional, and should be placed in the order 'before', 'separator', 'after'. You can use HTML inside each of the fields.

变数都是可选择的,而且应该以'前', '分隔符', '后'的顺序排列。你可以在每个区内使用HTML。

Example

例子

A Basic Example

一个基本的例子

This outputs the list of tags inside a paragraph, with tags separated by commas.

这在一个段落中产生了一列标签,标签是用逗号分开的。

<?php
echo get_the_tag_list('<p>Tags: ',', ','</p>');
?>
<?php
echo get_the_tag_list('<p>Tags: ',', ','</p>');
?>

This would return something like. 这会返回:

<p>
Tags: 
<a href="tag1">Tag 1</a>, 
<a href="tag2">Tag 2</a>, ... 
</p>
<p>
标签: 
<a href="tag1">Tag 1</a>, 
<a href="tag2">Tag 2</a>, ... 
</p>

A Slightly More Complex Example

A Slightly More Complex Example

一个稍微复杂的例子

This checks if the post has any tags, and if there are, outputs them to a standard unordered list.

这个例子检查文章是否含有任何标签,如果文章含有标签,将标签放到一个标准的无序列表上。

<?php
if(get_the_tag_list()) {
 get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
}
?>
<?php
if(get_the_tag_list()) {
 get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
}
?>

This will return something in the form: 这会返回以这个形式出现的内容;

<ul>
<li><a href="tag1">Tag 1</a></li>
<li><a href="tag2">Tag 2</a></li>
 ... 
</ul>
<ul>
<li><a href="tag1">Tag 1</a></li>
<li><a href="tag2">Tag 2</a></li>
 ... 
</ul>

You can add classes and styles with CSS, as necessary./ 如果需要的话,你可以添加CSS的class和样式。/

模板:Tag Tag Tags

模板:PHP Function Tag Footer

This page is [[WordPress::Category:Stubs|marked]] as incomplete. You can help Codex by expanding it.

模板:标签标签 标签

This page is [[WordPress::Category:Stubs|marked]] as incomplete. You can help Codex by expanding it.