I've created a taxonomy.php page in my wordpress template 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
I've created a taxonomy.php page in my wordpress template 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
Simple and easy!
Just copy paste below code!
This will print your current taxonomy name and description(optional)
If you are in taxonomy page.
That's how you get all details about the taxonomy.
This is how you get the taxonomy id
But if you are in post page (taxomony -> child)
See wp_get_post_terms(), you'd do something like so:
Here's the whole code snippet needed:
It's the term slug you want.Looks like you can get the id like this if that's what you need: