category_description

Sponsored Link

現在のカテゴリー (Posts > Categories)のカテゴリー設定画面で定義したカテゴリーの説明を返します。

Sponsored Link

Returns the description of a category defined in the category settings screen for the current category (Posts > Categories).

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

<?php echo category_description( $category ); ?> 

category_descriptionのパラメーター

$category

(integer) タグが説明を返すカテゴリーの数字IDです。もし1つしか設定されていない場合、デフォルトは現在のカテゴリーです。

(integer) The numeric ID of the category for which the tag is to return the description. Defaults to the current category, if one is not set.

デフォルトの使い方

タグの戻り値をエコーすることによって、カテゴリー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>

結果:

Result:

WordPressは私のお気に入りのブログのツールで、私はWordPressのここを使用してチップやトリックを共有しています。

WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.

注:カテゴリーの説明がない場合、この関数はbrタグを返します。

Note: 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> 

結果:

Result:

現在のWordPressを参照する:WordPressは私のお気に入りのブログのツールで、私はWordPressのここを使用してチップやトリックを共有しています。

Currently browsing WordPress: WordPress is a favorite blogging tool of mine and I share tips and tricks for using WordPress here.

関連テンプレートタグ

the_category, the_category_rss, single_cat_title, category_description, wp_dropdown_categories, wp_list_categories, get_the_category, get_category_parents, get_category_link, is_category, in_category

Sponsored Link