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

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

1 Answer 1

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.