Is there a built in wordpress function that let’s me look up the
“parent” field of the wp_term_taxonomy
table if I pass the TT_ID
to
it?
Something like
get_value ( $wp_table_name, $id_fieldname, $id_value,
$the_field_info_to_retrieve )
Example
get_value ( "wp_term_taxonomy", "term_taxonomy_id", "parent");
My experience with this was that it is an issue area of the taxonomy system in core. In several cases the core code does fetch info based on a tt_id or an array of them, but in each of these cases it is painfully done with a custom SQL query inside that particular function rather than an API function.
To solve my own problem I wrote a simple helper function that should probably be in core. It doesn’t fetch a specific field but instead the entire term_taxonomy row (including ->parent). Ultimately this is no slower than getting a single field and it is a very fast query due to checking for a specific ID.
Try this-
Ref: https://codex.wordpress.org/Function_Reference/get_term
The below code will create a column on the user table (users.php) and display the name of a taxonomy term. This is for you if you had users with an assigned custom role. The database will only display the id in an object, but this code will extract the name from the ID and display it on the users table: