如何在 WordPress 中获取当前的分类术语 ID(不是 slug)? [英] How to get the current taxonomy term ID (not the slug) in WordPress?

查看:26
本文介绍了如何在 WordPress 中获取当前的分类术语 ID(不是 slug)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 WordPress 主题文件夹中创建了一个 taxonomy.php 页面.我想获取函数的当前术语 ID.我怎样才能得到这个?

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') 只返回术语 slug,我想要 ID

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

推荐答案

没关系!我找到了:)

get_queried_object()->term_id;

这篇关于如何在 WordPress 中获取当前的分类术语 ID(不是 slug)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆