I have a Taxonomy type named: Products:product_cat

I need the term names inside this field in an array. Is there any way to get them?


You can retrieve a taxonomies terms with get_terms().

Via their docs:

$terms = get_terms( array(
    'taxonomy' => 'product_cat',
    'hide_empty' => false,

And it returns:

(array|int|WP_Error) List of WP_Term instances and their children. Will return WP_Error, if any of $taxonomies do not exist.

Which you can view by doing somthing like

echo "<pre>".print_r($terms,true)."</pre>";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.