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

I need to be able to switch between the current page taxonomy so I can load in the appropriate menu:

$current_tax = 'need to get this from somewhere';
switch ($current_tax) {
    case 'tax1':
        // load menu1
    case 'tax3':
        // load menu2

I'm not sure which method is best to get the current page's taxonomy.

share|improve this question
What do you mean under taxonomy? tag, category or custom taxonomy? Read this to define more clear – Alexey Oct 9 '11 at 23:19
up vote 0 down vote accepted

Just replace tax_name with the desired taxonomie

$tax = wp_get_post_terms($post->ID, 'tax_name');
echo $tax[0]->slug;
share|improve this answer
$the_terms = get_the_terms($postid, 'custom_taxonomy' ); – dcolumbus Oct 10 '11 at 3:06

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.