WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a strange question...

I have my term as a variable...

$mailer = 'may-2012-newsletter';

And I'm trying to echo on my page the Name of my term, using the variable above. But this is not in a loop.

My term name is: May 2012 Newsletter

But I'm trying to echo this from using my term slug: may-2012-newsletter

This term is grouped in my taxonomy called: mailers

I've tried this below but this doesn't work? I think I'm totally off track.

<title><?php echo get_term_by( 'name', $mailer, 'mailers'); ?></title>

Any help would be awesome thanks.


share|improve this question
up vote 2 down vote accepted

You can use get_term_by to get the term object if you know the slug and then just echo out the name ex:

$by = 'slug';
$slug = 'may-2012-newsletter';
$taxonomy = 'mailers';
$term = get_term_by( $by, $slug, $taxonomy);
echo $term->name;
share|improve this answer
Ahhh thank you @Bainternet - worked a beaut!!! – Joshc May 22 '12 at 13:02

Your Answer


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.