the_tags – WordPress*リファレンス

まず最初に、WordPressバージョン2.3で利用可能です、このテンプレートタグはポストが属すタグかタグへのリンクを表示します。 どんなタグも現在のエントリーに関連していないなら、代わりに関連カテゴリを表示します。 このタグは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 The Loop.

the_tagsのテンプレートタグ使用方法

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

それの後にlinebreakがあるタグのリストを表示します。

原文⇒Displays a list of the tags with a linebreak after it.

<php the_tags('Tags:', ', ', '<br />'); ?>

デフォルトの使い方

各タグ(1以上であるなら)があるデフォルト用法リストタグがコンマ(,)で分離した、デフォルトテキストTagsと共に先行されています: .

原文⇒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>

Tags: WordPress, Computers, Blogging

矢印で区切る

(>)矢があるタグへのリンクを表示する、タグを分離して、テキストSocialが以下にタグ付けをしている状態で、先行されています。

原文⇒Separated by Arrow

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

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

Social tagging: WordPress > Computers > Blogging

中黒点で区切る

中黒(・)が以下でタグを分離して、テキストTaggedと共に先行されている状態で、タグへのリンクを表示します。 そして、線が支えて、壊れてください。

原文⇒Separated by a Bullet

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

<?php
the_tags('Tagged with: ',' &amp;bull; ','<br />');
?>

Tagged with: WordPress • Computers • Blogging

リストの例

本当の、そして、簡単な(X)HTMLが以下を記載するような(<ul>/<ol>/<dl>)タグのリストを表示します。

原文⇒A List Example

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

<?php
the_tags('<ul><li>','</li><li>','</li>');
?>

  • WordPress
  • Computers
  • Blogging

カテゴリーとタグを統合する

カテゴリに関連している既存のポストを持って、また、ポストにタグを加え始めたなら、あなたは各ポストでカテゴリとタグの統合リストを見せたがっているかもしれません。 例えば、文化と呼ばれるカテゴリを先在させて、メディアを持って、ポスト「芸術」と「絵」にタグを加えたと仮定してください。 読者の経験を簡素化して、ものを整え続けるために、あなたはまるでそれらがすべてタグであるかのようにこれらを表示したがっているかもしれません:

原文⇒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(); ?>

the_tagsのパラメーター

before

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

separator

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

after

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

関連テンプレートタグ

the_tags,get_the_tags,get_the_tag_list,
single_tag_title,is_tag,get_tag_link,wp_tag_cloud,
wp_generate_tag_cloud


HOME » テンプレートタグ » タグ tags » the_tags – WordPress*リファレンス