I am having a very frustrating time figuring out how to access certain details from my website’s MySQL database using WordPress’ built-in functions. I feel like the solution must be extremely simply, but I just don’t know what it is.
I’m building for my website a WordPress plugin that is meant to retrieve certain pieces of information from the MySQL database. I’m trying to search for a specific taxonomy name, “product_shipping_class”, in the wp_term_taxonomy table, find each entry that matches that taxonomy name, and then locate the corresponding term id’s in wp_terms, so that I can extract the names of those entries.
I have included a screenshot that shows exactly what I’m trying to do.
The MySQL entries in question were created by the WooCommerce plugin, if that makes any difference.
I have tried to experiment with every seemingly appropriate WordPress function to search through the database, with no usable results and with no clue how to continue.
These are the functions I’ve used:
get_object_taxonomies
get_taxonomy
get_taxonomies
get_term
get_terms
is_taxonomy
taxonomy_exists
I am new to using WordPress-specific PHP functions, so I may very well have used these functions wrong. I simply don’t know.
If I execute and print the output of get_taxonomy('category'), I get an array that contains actual information. Likewise, if I run get_taxonomy('nav_menu'), the function seems to run successfully and outputs information.
However, if I run get_taxonomy('product_shipping_class'), I merely get an output of FALSE. The same thing happens if I use get_taxonomy with any taxonomy that I know has been added by WooCommerce. The taxonomies created by the native WordPress installation seem to be the only ones that produce results.
I feel that I am most likely missing something very fundamental about how taxonomies and terms work, and how these functions work. I’d be very grateful to anybody willing to explain.