- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「テンプレートタグ/category description」の版間の差分
細 (1 版) |
(01:34, 21 February 2011 Ramiy 版を反映。一部未翻訳です。) |
||
1行目: | 1行目: | ||
− | + | {{NeedTrans|一部}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | [[en:Template Tags/category_description | + | <div id="Description"> |
+ | == 説明 == | ||
+ | カテゴリー管理画面(投稿 > カテゴリー)で設定したカテゴリーの説明をPHPの値として返します。 | ||
+ | archive.php テンプレートで使う場合、条件文 is_category() の内側で使ってください。そうでない場合、この関数は日別アーカイブやその他のアーカイブページの処理を停止します。 | ||
+ | </div> | ||
+ | <div id="Usage"> | ||
+ | == 使い方 == | ||
+ | |||
+ | <?php echo category_description( $category_id ); ?> | ||
+ | </div> | ||
+ | <div id="Parameters"> | ||
+ | == パラメータ == | ||
+ | {{Parameter|$category_id|整数|説明を取得したいカテゴリーID(数字)。|オプション|現在のページのカテゴリーID。}} | ||
+ | </div> | ||
+ | <div id="Example"> | ||
+ | == 用例 == | ||
+ | ===基本=== | ||
+ | |||
+ | Displays the description of a category, given its id, by echoing the return value of the tag. If no category given and used on a category page, it returns the description of the current category. | ||
+ | |||
+ | <pre> | ||
+ | <div><?php echo category_description(3); ?></div> | ||
+ | </pre> | ||
+ | 出力例: | ||
+ | |||
+ | WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here. | ||
+ | |||
+ | 注意: if there is no category description, the function returns a br tag. | ||
+ | |||
+ | ===カテゴリースラッグから取得する=== | ||
+ | |||
+ | Displays the description of a category, using a category slug. | ||
+ | |||
+ | <pre><?php echo category_description( get_category_by_slug('category-slug')->term_id ); ?></pre> | ||
+ | |||
+ | ===カテゴリータイトルと一緒に表示=== | ||
+ | |||
+ | <pre> | ||
+ | <div><strong><?php single_cat_title('Currently browsing'); ?> | ||
+ | </strong>: <?php echo category_description(); ?></div> | ||
+ | </pre> | ||
+ | |||
+ | 出力例: | ||
+ | |||
+ | '''Currently browsing WordPress:''' WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here. | ||
+ | </div> | ||
+ | <div id="Change Log"> | ||
+ | == 変更履歴 == | ||
+ | * Since: 1.0.0 | ||
+ | </div> | ||
+ | <div id="Notes"> | ||
+ | == 注 == | ||
+ | * [[テンプレートタグ/term description|<tt>term_description()</tt>]]/[[:en:Function Reference/term description|en]] を使用。 | ||
+ | </div> | ||
+ | <div id="Source File"> | ||
+ | == ソースファイル == | ||
+ | <tt>category_description()</tt> は {{Trac|wp-includes/category-template.php}} にあります。 | ||
+ | </div> | ||
+ | <div id="Related"> | ||
+ | == 関連 == | ||
+ | |||
+ | {{Tag Category Tags}} | ||
+ | </div> | ||
+ | |||
+ | {{Tag Footer}} | ||
+ | {{原文|Template Tags/category_description|100816}}<!-- 01:34, 21 February 2011 Ramiy 版 --> |
2013年4月8日 (月) 20:12時点における版
このページ「テンプレートタグ/category description」は一部未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
説明
カテゴリー管理画面(投稿 > カテゴリー)で設定したカテゴリーの説明をPHPの値として返します。 archive.php テンプレートで使う場合、条件文 is_category() の内側で使ってください。そうでない場合、この関数は日別アーカイブやその他のアーカイブページの処理を停止します。
使い方
<?php echo category_description( $category_id ); ?>
パラメータ
- $category_id
- (整数) (オプション) 説明を取得したいカテゴリーID(数字)。
- 初期値: 現在のページのカテゴリーID。
用例
基本
Displays the description of a category, given its id, by echoing the return value of the tag. If no category given and used on a category page, it returns the description of the current category.
<div><?php echo category_description(3); ?></div>
出力例:
WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.
注意: if there is no category description, the function returns a br tag.
カテゴリースラッグから取得する
Displays the description of a category, using a category slug.
<?php echo category_description( get_category_by_slug('category-slug')->term_id ); ?>
カテゴリータイトルと一緒に表示
<div><strong><?php single_cat_title('Currently browsing'); ?> </strong>: <?php echo category_description(); ?></div>
出力例:
Currently browsing WordPress: WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.
変更履歴
- Since: 1.0.0
注
- term_description()/en を使用。
ソースファイル
category_description() は wp-includes/category-template.php
にあります。
関連
カテゴリータグ: the_category(), the_category_rss(), single_cat_title(), category_description(), wp_dropdown_categories(), wp_list_categories(), get_the_category(), get_the_category_by_ID(), get_category_by_slug(), get_the_category_list(), get_category_parents(), get_category_link(), is_category(), in_category()
最新英語版: WordPress Codex » Template Tags/category_description (最新版との差分)