I'm trying to wrap a category name in a post with a div. This is how i get the category name I need.

Reference Links :

My Ideas

 <?php $term = term_exists('foo', 'category'); ?>
 <?php $term = get_term_by('name', 'foo', 'category') ?>

I need to wrap $term in a div. But I still can't figure it how.


get_term_by returns an object by default, so you could output the term name using

    $term = get_term_by('name', 'foo', 'category');
    echo "<div>$term->name</div>";
| improve this answer | |

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.