Reference › Functions wp_get_post_terms ( int $post_id = 0 , string | string[] $taxonomy = 'post_tag' , array $args = array() ): array | WP_Error
Since 2.8.0
Source wp-includes/post.php:4250Parameters Return Uses Used by Source History Retrieves the terms for a post.
Parameters
$post_idint optional The Post ID. Does not default to the ID of the global $post. Default 0.Default: 0
$taxonomystring | string[]optional The taxonomy slug or array of slugs for which to retrieve terms. Default 'post_tag'.Default: 'post_tag' $argsarray optional Term query parameters. See WP_Term_Query::__construct() for supported arguments.Default: array() Return
array | WP_ErrorArray of WP_Term objects on success or empty array if no terms were found. WP_Error object if $taxonomy doesn't exist. Source View on Trac ↗ View on GitHub ↗
4250 function wp_get_post_terms ( $post_id = 0 , $taxonomy = 'post_tag' , $args = array ( ) ) { 4251 $post_id = ( int ) $post_id ; 4252 4253 $defaults = array ( 'fields' => 'all' ) ; 4254 $args = wp_parse_args ( $args , $defaults ) ; 4255 4256 $tags = wp_get_object_terms ( $post_id , $taxonomy , $args ) ; 4257 4258 return $tags ; 4259 } History Introduced in 2.8.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.