WordPress:Template Tags/the tags
描述[ ]
這個標簽首先出現在WordPress2.3版本中,這個模板標簽顯示一個鏈接,鏈接到文章屬于的一個或者幾個標簽。如果沒有哪個標簽與當前文章有關,就會顯示與當前文章相關的類別。應該在The Loop內使用這個標簽。
用法[ ]
%%% <?php the_tags('before', 'separator', 'after'); ?> %%%
例子[ ]
顯示標簽的一個列表,后面加上一個行分隔符。
%%% <?php the_tags('Tags:', ', ', '
'); ?> %%%
默認用法[ ]
默認用法,列出標簽(如果多于一個標簽的話),標簽之間加上逗號,而且在默認文本標簽: 的前面。
<p><?php the_tags(); ?></p>
div style="border:1px solid blue; width:50%; padding:10px">Tags: WordPress, 電腦, 寫博客
用箭頭分開[ ]
顯示鏈接,鏈接到標簽,用一個箭頭(>)分開標簽,而且箭頭的前面有文本Social tagging:
<?php the_tags('Social tagging: ',' > '); ?>
由一個Bullet分開[ ]
顯示鏈接,鏈接到標簽,用bullet (•)分開標簽,而且bullet前面有文本Tagged with: ,后面由一個行分隔符。
%%%<?php
the_tags('Tagged with: ',' • ','
');
?>%%%
A List例子[ ]
顯示一列標簽作為真正而且簡單的(X)HTML列表(<ul> / <ol> / <dl> ):
%%%<?php
the_tags('
- ','
- ','
');
?>%%%
將類別和標簽結合[ ]
你已經有了與類別有關的文章,而且開始向文章添加標簽,你可能想要在每篇文章的下面顯示類別和標簽結合的一個列表。例如,假如你已經有了一個類別稱為文化和媒體,而且已經添加了標簽到稱為"美術" 和"繪畫"的文章中。要讓讀者感到更簡單而且保持內容清晰明了,如果這些都是標簽,你可能想要顯示:
標簽: 文化,媒體,美術,繪畫
這個編碼幫你解決了問題,而且對于當前文章如果這個代碼是非空的,就會產生類別或者標簽。 %%% 標簽: <?php if (the_category(', ')) the_category(); ?> <?php if (get_the_tags()) the_tags(); ?> %%%
參數[ ]
- before
- (string) 真正的標簽顯示之前,顯示的文本。默認為標簽:
- separator
- (string) 每個標簽鏈接之間顯示的文本或者字符。默認為每個標簽之間有個逗號(,)。
- after
- (string) 最后一個標簽之后顯示的文本。默認為不顯示任何內容。
相關的[ ]
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.