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

来自站长百科
跳转至: 导航、​ 搜索
无编辑摘要
无编辑摘要
 
第1行: 第1行:
== 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'内使用这个标签。
创建与当前文章相关的标签的HTML字符串。每个标签的名称会链接到相关的'标签'网页。你可以命令函数在所有的标签前后放置一个字符串,而且在每个标签之间也放置一个字符串。必须在'The Loop'内使用这个标签。
== 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>.


这个函数不显示任何内容 – 如果你想要直接地将这个函数放到网页上,你应该使用<code>echo (get_the_tag_list())</code>。另外,你可以通过使用<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.
变数都是可选择的,而且应该以'before', 'separator', 'after'的顺序排列。你可以在每个区内使用HTML。
 
变数都是可选择的,而且应该以'前', '分隔符', '后'的顺序排列。你可以在每个区内使用HTML。
 
== Example ==


== 例子 ==
== 例子 ==
=== A Basic Example ===


===一个基本的例子===
===一个基本的例子===
This outputs the list of tags inside a paragraph, with tags separated by commas.


这在一个段落中产生了一列标签,标签是用逗号分开的。
这在一个段落中产生了一列标签,标签是用逗号分开的。
第37行: 第21行:
</pre>
</pre>


<pre>
<?php
echo get_the_tag_list('<p>Tags: ',', ','</p>');
?>
</pre>
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>
第60行: 第29行:
</p>
</p>
</pre>
</pre>
=== 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.


这个例子检查文章是否含有任何标签,如果文章含有标签,将标签放到一个标准的无序列表上。
这个例子检查文章是否含有任何标签,如果文章含有标签,将标签放到一个标准的无序列表上。
第81行: 第42行:
</pre>
</pre>


<pre>
<?php
if(get_the_tag_list()) {
get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
}
?>
</pre>
This will return something in the form:
这会返回以这个形式出现的内容;
这会返回以这个形式出现的内容;
<pre>
<pre>
<ul>
<ul>
第100行: 第51行:
</pre>
</pre>


<pre>
<ul>
<li><a href="tag1">Tag 1</a></li>
<li><a href="tag2">Tag 2</a></li>
...
</ul>
</pre>
You can add classes and styles with CSS, as necessary./
如果需要的话,你可以添加CSS的class和样式。/
如果需要的话,你可以添加CSS的class和样式。/
{{Tag Tag Tags}}
{{PHP Function Tag Footer}}
{{Stub}}


{{标签标签 标签}}
{{标签标签 标签}}

2008年7月19日 (六) 14:34的最新版本

描述[ ]

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

用法[ ]

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

变数都是可选择的,而且应该以'before', 'separator', 'after'的顺序排列。你可以在每个区内使用HTML。

例子[ ]

一个基本的例子[ ]

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

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

这会返回:

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

一个稍微复杂的例子[ ]

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

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

这会返回以这个形式出现的内容;

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

如果需要的话,你可以添加CSS的class和样式。/

模板:标签标签 标签

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