get_the_category() WP 1.0
Retrieve post categories.
This tag may be used outside The Loop by passing a post ID as the parameter.
Note: This function only returns results from the default "category" taxonomy. For custom taxonomies use get_the_terms().
Works based on: get_the_terms()
Basis of: get_the_category_list()
Hooks from the function
Return
WP_Term[]. Array of WP_Term objects, one for each category assigned to the post.
Usage
get_the_category( $post_id );
- $post_id(int)
- The post ID.
Default: current post ID
Changelog
Since 0.71 | Introduced. |
Code of get_the_category() get the category WP 5.6
Related Functions
From category: For posts
- get_object_taxonomies()
- get_objects_in_term()
- get_the_category_list()
- get_the_tag_list()
- get_the_tags()
- get_the_taxonomies()
- get_the_term_list()
- get_the_terms()
- has_category()