0

I would like to know how to change category id's to the actual name of the category and vice versa. for example if i run

$lob = $values[data]->tag_ids;

$lob with then equal

Array
(
[0] => 184
[1] => 135
[2] => 185
)

How do I convert that array into an array with the names? Thanks guys.

0

You can use get_term() to get the full term objects which contain the name. If you do this in array_map() you can convert the IDs in the array to the name:

$lob = $values[data]->tag_ids;

$names = array_map( function( $term_id ) {
    $term = get_term( $term_id );

    return $term->name;
}, $lob );

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.