wp_get_post_terms returns WP_Error
-
Hi,
For some reason the following line$terms = wp_get_post_terms($p->ID, ‘item_year’);
returns WP_Error.
According to https://developer.www.ads-software.com/reference/functions/wp_get_post_terms/ it means that no terms were found.
‘item_year’ is the name of the taxonomy I created and each post has a value for it.
$p represents post id from type: post.
When changing ‘item_year’ to ‘post_tag’ and adding echo statement to show the id and first tag of each post, I got the correct results so I believe it shows that my loop is correct and the problem is with the taxonomy ‘item_year’…
Any help will be much appreciated.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘wp_get_post_terms returns WP_Error’ is closed to new replies.