get_the_category和get_the_terms貌似都是用来获取分类信息的,
前者使用方法简单,不带参数,后者使用方法
例如:woocommerce中,获取当前产品页面的分类信息,前者居然无效,后者要使用
为什么要填写'product_cat',我怎么知道这里为什么必须写product_cat,而不是product_cat1,从何得知?
请大神讲解一下什么时候用前者?什么时候用后者,两者的具体区别是什么?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
woocommerce/includes/class-wc-post-types.php 里面注册了一个分类 商城系统应该是读取的这个
get_the_category是调用wordpress自定义的文章分类
get_the_terms是调用用户开发时定义的分类类型,也可以调用wordpress自定义的