get_terms() returns an empty array

get_terms returns an array of objects. You cannot echo an array, if you do, you will just get Array(). What you can do is print_r($array) or var_dump($array) or echo json_encode($array) to see the data it contains.

Otherwise, to get single elements, e.g. the name, from the objects, you need to pass $tax_terms through a foreach loop to get the objects from each term and then from there you can also then echo the specific object you are after

Something like this will work

$tax_terms = get_terms( $taxonomy, $args );

foreach ( $tax_terms as $tax_term ) {

    echo $tax_term->name;

}

Leave a Comment