Saturday, January 31, 2015

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:

$tax_slug = get_query_var( 'event-categories' );
echo $tax_slug;

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


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