Monday, May 16, 2022

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

Issue

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


Solution

Nevermind! I found it :)

get_queried_object()->term_id;


Answered By - InvalidSyntax
Answer Checked By - Mary Flores (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.