Can I get the term by its id without knowing to which taxonomy it belongs?
I have a meta field that stores term ids, but doesn’t store the taxonomy. However, all the get_term
function have taxonomy parameter marked as required.
Maybe I can get the taxonomy of the term by its (term’s) id somehow?
Yes, but you need you make your own SQL query.
A modified version of WP’s get_term():
Probably not a good idea. Try to handle the tax too in your meta fields…
I accepted One Trick Pony’s answer because it got me on the right track and it does answer my question.
However, in the end I am using this, it returns full term object with it’s taxonomy fields. Though it’s a bit hacky…
This is a very old question, but I’m leaving the answer using only a WP method. It’s possible to do it with
[get_terms( WP_Term_Query_array )][1]
using theinclude
param (an array of the terms ids):The method returns an array of WP Term objects.
More information about the WP_Term_Query object and its params.