Sponsored Link
カテゴリースラッグによってカテゴリーオブジェクトを取得します。見つからない場合はfalseを返します。
Sponsored Link
Retrieve category object by category slug. Returns false if not found.
get_category_by_slugのファンクションタグ使用方法
<?php get_category_by_slug( $slug ) ?>
get_category_by_slugのパラメーター
$slug
(string) (required) カテゴリースラッグ
Default: なし
(string) (required) The category slug.
Default: None
戻り値
(object)
カテゴリーのデータオブジェクト
Category data object.
(boolean)
見つからない場合はfalse
false if not found
例
<?php $idObj = get_category_by_slug('category-name'); $id = $idObj->term_id; ?>
注意
- 用途:get_term_by()は、カテゴリーオブジェクトを取得します。
- 用途:カテゴリーオブジェクトを作るための_make_cat_compat()は、WordPress2.3.0およびそれ以前のバージョンとの互換性を持たせました。
- Uses: get_term_by() to get the category object
- Uses: _make_cat_compat() to make category object compatible with WP 2.3.0 and earlier versions.
変更ログ
Since: 2.3.0
ソースファイル
get_category_by_slug()は、wp-includes/category.php内に位置しています。
get_category_by_slug() is located in wp-includes/category.php.
関連ファンクションタグ
Categories: 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()