0

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

2

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;

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.