Get slug of the current archive page of a taxonomy in Wordpress

To get the taxonomy slug of the current archive page, for example:

You installed an event plugin which allows you to create session tracks ("session-track", a taxonomy), e.g: session-1, session-2... (terms) And in the archive page of those session tracks, to get the slug of the current one, you just need to call:

<?php
$tax_slug = get_query_var( 'event-categories' );
echo $tax_slug;
?>

If you are on session track 1 archive page, the result will be:

session-1

For more information about taxonomies and terms in WordPress, please read:

[0] http://codex.wordpress.org/Taxonomies
[1] http://code.tutsplus.com/tutorials/understanding-and-working-with-taxonomies-and-terms-in-wordpress--cms-21051

Comments