diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 8cf66c53bc..e45734abbb 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -1062,9 +1062,6 @@ function get_the_terms( $post, $taxonomy ) { if ( ! $post = get_post( $post ) ) return false; - if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) - return false; - $terms = get_object_term_cache( $post->ID, $taxonomy ); if ( false === $terms ) { $terms = wp_get_object_terms( $post->ID, $taxonomy ); diff --git a/wp-includes/post.php b/wp-includes/post.php index 1cc76b9af9..3eaa5620d4 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -615,16 +615,20 @@ final class WP_Post { } if ( 'post_category' == $key ) { - $terms = get_the_terms( $this, 'category' ); - if ( ! $terms ) + if ( is_object_in_taxonomy( $this->post_type, 'category' ) ) + $terms = get_the_terms( $this, 'category' ); + + if ( empty( $terms ) ) return array(); return wp_list_pluck( $terms, 'term_id' ); } if ( 'tags_input' == $key ) { - $terms = get_the_terms( $this, 'post_tag' ); - if ( ! $terms ) + if ( is_object_in_taxonomy( $this->post_type, 'post_tag' ) ) + $terms = get_the_terms( $this, 'post_tag' ); + + if ( empty( $terms ) ) return array(); return wp_list_pluck( $terms, 'name' );