Passing array of taxonomies to the_terms() triggers "array to string" conversion warning
|Reported by:||johnjamesjacoby||Owned by:|
To duplicate in a loop, call:
the_terms( get_the_ID(), array( 'category', 'post_tag' ) );
I expected to output the terms for a post across multiple taxonomies. Instead, an array to string conversion warning is returned.
I've narrowed this down to an inconsistency in the way caching is handled between update_object_term_cache() and get_object_term_cache(), namely that update handles multiple taxonomies and relationships, and get assumes only one taxonomy is passed.
The call stack to the error looks something like:
Each of the functions in the above stack safely handles multiple taxonomies, except for get_object_term_cache(). If get_object_term_cache() were fixed, wp_get_object_terms() would fire (which also safely handles multiple taxonomies) and the_terms() would work as I expected.
Change History (7)
3 years ago
- Keywords has-patch needs-unit-tests added; 2nd-opinion removed
- Milestone changed from Awaiting Review to Future Release