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.

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.

Josh

share|improve this question
add comment

1 Answer

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
add comment

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.