I'm querying a custom taxonomy for a post, hoping to get a list of all terms for that post and taxonomy. get_the_terms($post_id, $taxonomy)
works, but gives this ungodly array of term objects that will require an extra layer of parsing before I can run the following code:
if (in_array($list_of_term_ids, $my_term_id)){ do good stuff... }
I'm looking to see whether anyone has come across a native WP function or method that extracts term ids into a flat list before rolling my own utility function, just so I can be using built-in best practices.
$term_ids = array_map(function($a){return $a->term_id;}, get_the_terms($post->ID, TAXONOMY_NAME));
You could of course do this with create_function instead:$term_ids = array_map(create_function('$a','return $a->term_id;'), get_the_terms($post->ID, TAXONOMY_NAME));
for php 4+. Still, if there's a better way, I'd love to hear it!