Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

If I know a taxonomy term slug, how can I get that term's name?

share|improve this question
    
are you wanting to create a link, title, ??? –  xLRDxREVENGEx May 5 '11 at 5:10

1 Answer 1

up vote 11 down vote accepted

The function you are looking for is get_term_by. You would use it as such:

<?php $term = get_term_by('slug', 'my-term-slug', 'category'); $name = $term->name; ?>

This results in $term being an object containing the following:

term_id
name
slug
term_group
term_taxonomy_id
taxonomy
description
parent
count

The codex does a great job explaining this function: http://codex.wordpress.org/Function_Reference/get_term_by

share|improve this answer
    
you beat me to it. This is exactly what i would do to. –  xLRDxREVENGEx May 5 '11 at 5:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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