Languages: English • 한국어 • 日本語 (Add your language)
Retrieves category data given a category ID or category object.
If you pass the $category parameter an object, which is assumed to be the category row object retrieved the database. It will cache the category data.
If you pass $category an integer of the category ID, then that category will be retrieved from the database, if it isn't already cached, and pass it back.
If you look at get_term(), then both types will be passed through several filters and finally sanitized based on the $filter parameter value.
The category will converted to maintain backwards compatibility.
Note: use get_term() to get Link Categories based on their ID's. get_category only returns Post Categories.
<?php get_category( $category, $output, $filter ) ?>
null
if $category does not exist.
<?php $thisCat = get_category(get_query_var('cat')); ?>
The variable $thisCat is now:
stdClass Object ( [term_id] => 85 [name] => Category Name [slug] => category-name [term_group] => 0 [term_taxonomy_id] => 85 [taxonomy] => category [description] => [parent] => 70 [count] => 0 [cat_ID] => 85 [category_count] => 0 [category_description] => [cat_name] => Category Name [category_nicename] => category-name [category_parent] => 70 )
count
attribute includes custom post types as well if the custom post type uses standard categories.get_category() is located in wp-includes/category.php
.