single_cat_title

Sponsored Link

現在のページのカテゴリータイトルを表示または返します。ページに関しては、カテゴリー(例えば”/tag/geek”)よりむしろWordPressタグを表示して、タグ名がカテゴリーの代わりに表示されます。ループ外で使用することはできません。

Sponsored Link

Displays or returns the category title for the current page. For pages displaying WordPress tags rather than categories (e.g. “/tag/geek”) the name of the tag is displayed instead of the category. Can be used only outside The Loop.

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

<?php single_cat_title( $prefix, $display ); ?> 

デフォルトの使い方

<?php single_cat_title(
'prefix'   => , 
'display'  => true ); ?> 

single_cat_titleのパラメーター

$prefix

(string) (optional) タイトルの前に出力するテキストです。

(string) (optional) Text to output before the title.

Default: None

$display

(boolean) (optional) タイトルを表示するか(TRUE)、PHPで使用するために返すか(FALSE)。

(boolean) (optional) Should the title be displayed (TRUE) or returned for use in PHP (FALSE).

Default: TRUE

この例では、カテゴリータイトルに続くテキストの”Currently browsing “テキストが表示されます。

This example displays the text “Currently browsing ” followed by the category title.

<p><?php single_cat_title('Currently browsing '); ?>.</p>

この例では、変数$current_categoryをPHPで使用するために現在のカテゴリータイトルに割り当てます。

Currently browsing WordPress.

This example assigns the current category title to the variable $current_category for use in PHP.

<?php $current_category = single_cat_title("", false); ?>

関連テンプレートタグ

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