I'm currently storing a string of comma separated taxonomy IDs in a text field for each user. I have managed to retrieve the string from a user which I've saved in a variable called '$user_terms'. I can split this string into an array of IDs called '$user_terms_array. I'm stuck now though as I need to get the name of the IDs. I found this:
https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
but I'm not particularly sure how to use this/ if I can use this in my situation. I also found this:
https://developer.wordpress.org/reference/functions/get_term/
But again I can't quite figure out how to use this. I tried the following:
$context['single_term'] = get_term( $user_terms_array[1], $taxonomy = 'terms' );
Then in my twig template if I try to output the value of single_term I get the following output in the HTML:
'https://www.w3-edge.com/products/
Object Caching 4429/6070 objects using disk Page Caching using disk: enhanced (User is logged in) Database Caching using disk (Request-wide User is logged in)
Served from: dev.url @ 2017-08-22 10:28:00 by W3 Total Cache -->'
Not quite sure where I'm going wrong.
Edit:
I tried this:
$context['single_term'] = get_term( $user_terms_array[1], $taxonomy = 'terms' )->name;
and it get no output, it's just blank.