WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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

can anyone help me with this?

I need to print the slug of my custom taxonomy, can this be done?

The following kind of works but it just shows the name, rather than the slug which i need for a class purpose..

<?php $terms = get_the_terms( $post->ID , 'area' ); foreach( $terms as $term ) {print $term->name; unset($term);}?>     

Any way of just getting the slug for my custom taxonomy 'area' ??

Many thanks for any help :)

share|improve this question
up vote 1 down vote accepted

Here is an example return of $term:

 stdClass Object (
                  [term_id] => 31
                  [name] => Architectural Items / Salvage
                  [slug] => architectural-items-salvage
                  [term_group] => 0
                  [term_taxonomy_id] => 31
                  [taxonomy] => dcategory
                  [description] =>
                  [parent] => 5
                  [count] => 10
                  [object_id] => 197

If you don't know what's in $term or any other variable then print_r() and var_dump() are your friend.

share|improve this answer
Brilliant thank you :) – user4630 May 17 '11 at 10:57

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.