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.

  • What do you mean under taxonomy? tag, category or custom taxonomy? Read this to define more clear – Alexey Oct 9 '11 at 23:19

Just replace tax_name with the desired taxonomie

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

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.