get_the_category和get_the_terms区别


Updated on: June 9, 2020 in Wordpress by

get_the_category( int $id = false )

Description #Description

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().

Parameters #Parameters

$id

(int) (Optional) default to current post ID. The post ID.

Default value: false


Top ↑

Return #Return

(WP_Term[]) Array of WP_Term objects, one for each category assigned to the post.

Retrieve post categories.