WordPress: Template Tags/the tags:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == Description == First available with WordPress Version 2.3, this template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, the...)
 
无编辑摘要
第1行: 第1行:
== Description ==
== Description ==
== 描述 ==
First available with WordPress Version 2.3, this template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, the associated category is displayed instead. This tag should be used within [[WordPress:The Loop]].
First available with WordPress Version 2.3, this template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, the associated category is displayed instead. This tag should be used within [[WordPress:The Loop]].
这个标签首先出现在WordPress2.3版本中,这个模板标签显示一个链接,链接到文章属于的一个或者几个标签。如果没有哪个标签与当前文章有关,就会显示与当前文章相关的类别。应该在[[WordPress:The Loop|The Loop]]内使用这个标签。


== Usage ==
== Usage ==
== 用法 ==
%%% <?php the_tags('before', 'separator', 'after'); ?> %%%
%%% <?php the_tags('before', 'separator', 'after'); ?> %%%
%%% <?php the_tags('before', 'separator', 'after'); ?> %%%


== Examples ==
== Examples ==
== 例子 ==
Displays a list of the tags with a linebreak after it.
Displays a list of the tags with a linebreak after it.
%%% <?php the_tags('Tags:', ', ', '<br />'); ?> %%%
%%% <?php the_tags('Tags:', ', ', '<br />'); ?> %%%
显示标签的一个列表,后面加上一个行分隔符。


===Default Usage===
===Default Usage===
===默认用法===
The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text '''Tags: '''.
The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text '''Tags: '''.
默认用法,列出标签(如果多于一个标签的话),标签之间加上逗号,而且在默认文本'''标签: '''的前面。
<pre><p><?php the_tags(); ?></p></pre>


<pre><p><?php the_tags(); ?></p></pre>
<pre><p><?php the_tags(); ?></p></pre>


<div style="border:1px solid blue; width:50%; padding:10px">Tags: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|Computers]], [[WordPress:#Examples|Blogging]]</div>
<div style="border:1px solid blue; width:50%; padding:10px">Tags: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|Computers]], [[WordPress:#Examples|Blogging]]</div>
div style="border:1px solid blue; width:50%; padding:10px">Tags: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|电脑]], [[WordPress:#Examples|写博客]]</div>




===Separated by Arrow===
===Separated by Arrow===
===用箭头分开===
Displays links to tags with an arrow (&gt;) separating the tags and preceded with the text '''Social tagging:'''
Displays links to tags with an arrow (&gt;) separating the tags and preceded with the text '''Social tagging:'''
显示链接,链接到标签,用一个箭头(&gt;)分开标签,而且箭头的前面有文本'''Social tagging:'''
<pre><?php the_tags('Social tagging: ',' > '); ?></pre>


<pre><?php the_tags('Social tagging: ',' > '); ?></pre>
<pre><?php the_tags('Social tagging: ',' > '); ?></pre>


<div style="padding: 10px; width: 50%; border:solid 1px blue">Social tagging: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|Computers]] > [[WordPress:#Examples|Blogging]]</div>
<div style="padding: 10px; width: 50%; border:solid 1px blue">Social tagging: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|Computers]] > [[WordPress:#Examples|Blogging]]</div>
<div style="padding: 10px; width: 50%; border:solid 1px blue">Social tagging: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|电脑]] > [[WordPress:#Examples|写博客]]</div>




===Separated by a Bullet===
===Separated by a Bullet===
===由一个Bullet分开===
Displays links to tags with a bullet (&bull;) separating the tags and preceded with the text '''Tagged with: ''' and followed by a line break.
Displays links to tags with a bullet (&bull;) separating the tags and preceded with the text '''Tagged with: ''' and followed by a line break.
显示链接,链接到标签,用bullet (&bull;)分开标签,而且bullet前面有文本'''Tagged with: ''',后面由一个行分隔符。
%%%<?php
    the_tags('Tagged with: ',' &amp;bull; ','<br />');
?>%%%


%%%<?php  
%%%<?php  
第33行: 第77行:


<div style="padding: 10px; width: 50%; border:solid 1px blue">Tagged with: [[WordPress:#Examples|WordPress]] &bull; [[WordPress:#Examples|Computers]] &bull; [[WordPress:#Examples|Blogging]]</div>
<div style="padding: 10px; width: 50%; border:solid 1px blue">Tagged with: [[WordPress:#Examples|WordPress]] &bull; [[WordPress:#Examples|Computers]] &bull; [[WordPress:#Examples|Blogging]]</div>
<div style="padding: 10px; width: 50%; border:solid 1px blue">Tagged with: [[WordPress:#Examples|WordPress]] &bull; [[WordPress:#Examples|电脑]] &bull; [[WordPress:#Examples|写博客]]</div>


===A List Example===
===A List Example===
===A List例子===
Displays a list of the tags as a real and simple (X)HTML list (&lt;ul&gt; / &lt;ol&gt; / &lt;dl&gt; ):
Displays a list of the tags as a real and simple (X)HTML list (&lt;ul&gt; / &lt;ol&gt; / &lt;dl&gt; ):
显示一列标签作为真正而且简单的(X)HTML列表(&lt;ul&gt; / &lt;ol&gt; / &lt;dl&gt; ):
%%%<?php
    the_tags('<ul><li>','</li><li>','</li></ul>');
?>%%%


%%%<?php  
%%%<?php  
第42行: 第99行:


<div style="padding: 10px; width: 50%; border:solid 1px blue"><ul><li>[[WordPress:#Examples|WordPress]]</li><li>[[WordPress:#Examples|Computers]]</li><li>[[WordPress:#Examples|Blogging]]</li></ul></div>
<div style="padding: 10px; width: 50%; border:solid 1px blue"><ul><li>[[WordPress:#Examples|WordPress]]</li><li>[[WordPress:#Examples|Computers]]</li><li>[[WordPress:#Examples|Blogging]]</li></ul></div>
<div style="padding: 10px; width: 50%; border:solid 1px blue"><ul><li>[[WordPress:#Examples|WordPress]]</li><li>[[WordPress:#Examples|电脑]]</li><li>[[WordPress:#Examples|写博客]]</li></ul></div>


===Integrating Categories and Tags===
===Integrating Categories and Tags===
===将类别和标签结合===


If you have existing posts associated with categories, and have started adding tags to posts as well, you may want to show an integrated list of categories and tags beneath each post. For example, assume you have pre-existing categories called Culture and Media, and have added tags to a post "Arts" and "Painting".  To simplify the reader's experience and keep things uncluttered, you may want to display these as if they were all tags:
If you have existing posts associated with categories, and have started adding tags to posts as well, you may want to show an integrated list of categories and tags beneath each post. For example, assume you have pre-existing categories called Culture and Media, and have added tags to a post "Arts" and "Painting".  To simplify the reader's experience and keep things uncluttered, you may want to display these as if they were all tags:
你已经有了与类别有关的文章,而且开始向文章添加标签,你可能想要在每篇文章的下面显示类别和标签结合的一个列表。例如,假如你已经有了一个类别称为文化和媒体,而且已经添加了标签到称为"美术" 和"绘画"的文章中。要让读者感到更简单而且保持内容清晰明了,如果这些都是标签,你可能想要显示:


<div style="padding: 10px; width: 50%; border:solid 1px blue">
<div style="padding: 10px; width: 50%; border:solid 1px blue">
Tags: Culture, Media, Arts, Painting
Tags: Culture, Media, Arts, Painting
</div>
<div style="padding: 10px; width: 50%; border:solid 1px blue">
标签: 文化,媒体,美术,绘画
</div>
</div>


This code will get you there, and will only render categories or tags if they're non-empty for the current post:
This code will get you there, and will only render categories or tags if they're non-empty for the current post:
这个编码帮你解决了问题,而且对于当前文章如果这个代码是非空的,就会产生类别或者标签。


%%%
%%%
Tags:
Tags:
<?php if (the_category(', '))  the_category(); ?>
<?php if (get_the_tags()) the_tags(); ?>
%%%
%%%
标签:
<?php if (the_category(', '))  the_category(); ?>
<?php if (the_category(', '))  the_category(); ?>
<?php if (get_the_tags()) the_tags(); ?>  
<?php if (get_the_tags()) the_tags(); ?>  
第60行: 第135行:


== Parameters ==
== Parameters ==
== 参数 ==
; before : (''string'') Text to display before the actual tags are displayed.  Defaults to '''Tags: '''
; before : (''string'') Text to display before the actual tags are displayed.  Defaults to '''Tags: '''
;之前: (''string'')真正的标签显示之前,显示的文本。默认为'''标签: '''
; separator : (''string'') Text or character to display between each tag link. The default is a comma (,) between each tag.
; separator : (''string'') Text or character to display between each tag link. The default is a comma (,) between each tag.
;分隔符:(''string'')每个标签链接之间显示的文本或者字符。默认为每个标签之间有个逗号(,)。
; after : (''string'') Text to display after the last tag.  The default is to display nothing.
; after : (''string'') Text to display after the last tag.  The default is to display nothing.
;之后:(''string'')最后一个标签之后显示的文本。默认为不显示任何内容。


== Related ==
== Related ==
== 相关的==
{{Tag Tag Tags}}
{{Tag Tag Tags}}


{{PHP Function Tag Footer}}
{{PHP Function Tag Footer}}


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

2008年7月10日 (四) 14:51的版本

Description

描述

First available with WordPress Version 2.3, this template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, the associated category is displayed instead. This tag should be used within WordPress:The Loop.

这个标签首先出现在WordPress2.3版本中,这个模板标签显示一个链接,链接到文章属于的一个或者几个标签。如果没有哪个标签与当前文章有关,就会显示与当前文章相关的类别。应该在The Loop内使用这个标签。

Usage

用法

%%% <?php the_tags('before', 'separator', 'after'); ?> %%%

%%% <?php the_tags('before', 'separator', 'after'); ?> %%%

Examples

例子

Displays a list of the tags with a linebreak after it. %%% <?php the_tags('Tags:', ', ', '
'); ?> %%% 显示标签的一个列表,后面加上一个行分隔符。

Default Usage

默认用法

The default usage lists tags with each tag (if more than one) separated by a comma (,) and preceded with the default text Tags: .

默认用法,列出标签(如果多于一个标签的话),标签之间加上逗号,而且在默认文本标签: 的前面。

<p><?php the_tags(); ?></p>
<p><?php the_tags(); ?></p>
Tags: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|Computers]], [[WordPress:#Examples|Blogging]]


div style="border:1px solid blue; width:50%; padding:10px">Tags: [[WordPress:#Examples|WordPress]], [[WordPress:#Examples|电脑]], [[WordPress:#Examples|写博客]]


Separated by Arrow

用箭头分开

Displays links to tags with an arrow (>) separating the tags and preceded with the text Social tagging:

显示链接,链接到标签,用一个箭头(>)分开标签,而且箭头的前面有文本Social tagging:

<?php the_tags('Social tagging: ',' > '); ?>
<?php the_tags('Social tagging: ',' > '); ?>
Social tagging: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|Computers]] > [[WordPress:#Examples|Blogging]]


Social tagging: [[WordPress:#Examples|WordPress]] > [[WordPress:#Examples|电脑]] > [[WordPress:#Examples|写博客]]


Separated by a Bullet

由一个Bullet分开

Displays links to tags with a bullet (•) separating the tags and preceded with the text Tagged with: and followed by a line break.

显示链接,链接到标签,用bullet (•)分开标签,而且bullet前面有文本Tagged with: ,后面由一个行分隔符。

%%%<?php

    the_tags('Tagged with: ',' &bull; ','
');

?>%%%

%%%<?php

    the_tags('Tagged with: ',' &bull; ','
');

?>%%%

Tagged with: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|Computers]] • [[WordPress:#Examples|Blogging]]
Tagged with: [[WordPress:#Examples|WordPress]] • [[WordPress:#Examples|电脑]] • [[WordPress:#Examples|写博客]]

A List Example

A List例子

Displays a list of the tags as a real and simple (X)HTML list (<ul> / <ol> / <dl> ):

显示一列标签作为真正而且简单的(X)HTML列表(<ul> / <ol> / <dl> ):

%%%<?php

the_tags('

  • ','
  • ','

');

?>%%%

%%%<?php

the_tags('

  • ','
  • ','

');

?>%%%

  • [[WordPress:#Examples|WordPress]]
  • [[WordPress:#Examples|Computers]]
  • [[WordPress:#Examples|Blogging]]
  • [[WordPress:#Examples|WordPress]]
  • [[WordPress:#Examples|电脑]]
  • [[WordPress:#Examples|写博客]]

Integrating Categories and Tags

将类别和标签结合

If you have existing posts associated with categories, and have started adding tags to posts as well, you may want to show an integrated list of categories and tags beneath each post. For example, assume you have pre-existing categories called Culture and Media, and have added tags to a post "Arts" and "Painting". To simplify the reader's experience and keep things uncluttered, you may want to display these as if they were all tags:

你已经有了与类别有关的文章,而且开始向文章添加标签,你可能想要在每篇文章的下面显示类别和标签结合的一个列表。例如,假如你已经有了一个类别称为文化和媒体,而且已经添加了标签到称为"美术" 和"绘画"的文章中。要让读者感到更简单而且保持内容清晰明了,如果这些都是标签,你可能想要显示:

Tags: Culture, Media, Arts, Painting

标签: 文化,媒体,美术,绘画

This code will get you there, and will only render categories or tags if they're non-empty for the current post:

这个编码帮你解决了问题,而且对于当前文章如果这个代码是非空的,就会产生类别或者标签。

%%% Tags: <?php if (the_category(', ')) the_category(); ?> <?php if (get_the_tags()) the_tags(); ?> %%%

%%% 标签: <?php if (the_category(', ')) the_category(); ?> <?php if (get_the_tags()) the_tags(); ?> %%%

Parameters

参数

before
(string) Text to display before the actual tags are displayed. Defaults to Tags:

;之前: (string)真正的标签显示之前,显示的文本。默认为标签:

separator
(string) Text or character to display between each tag link. The default is a comma (,) between each tag.

;分隔符:(string)每个标签链接之间显示的文本或者字符。默认为每个标签之间有个逗号(,)。

after
(string) Text to display after the last tag. The default is to display nothing.

;之后:(string)最后一个标签之后显示的文本。默认为不显示任何内容。

Related

相关的

模板:Tag Tag Tags

模板:PHP Function Tag Footer

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

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, previous_post_link, next_post_link, posts_nav_link, the_meta,

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