Skip to content

Instantly share code, notes, and snippets.

@chocotaro chocotaro/category_get Secret
Created Jan 20, 2020

Embed
What would you like to do?
category.phpでのカテゴリ取得方法
$category = get_category( get_query_var("cat") );
var_dump( $category );
// ↓ 返ってくるのはcategoryオブジェクト(未分類の例です)
object(stdClass)#1778 (16) {
["term_id"]=>
int(1)
["name"]=>
string(9) "未分類"
["slug"]=>
string(7) "unknown"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(1)
["taxonomy"]=>
string(8) "category"
["description"]=>
string(0) ""
["parent"]=>
int(0)
["count"]=>
int(102)
["filter"]=>
string(3) "raw"
["cat_ID"]=>
int(1)
["category_count"]=>
int(102)
["category_description"]=>
string(0) ""
["cat_name"]=>
string(9) "未分類"
["category_nicename"]=>
string(7) "unknown"
["category_parent"]=>
int(0)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.