How to get the current taxonomy term ID (not the slug) in WordPress?

InvalidSyntax picture InvalidSyntax · Sep 5, 2012 · Viewed 233k times · Source

I've created a taxonomy.php page in my WordPress theme folder. I would like to get the current term id for a function. How can I get this?

get_query_var('taxonomy') only returns the term slug, I want the ID

Answer

InvalidSyntax picture InvalidSyntax · Sep 5, 2012

Nevermind! I found it :)

get_queried_object()->term_id;