[英]Get custom taxonomy terms from custom post type
post_type: worker
post_type:
worker
custom worker
taxonomy: location
自定义
worker
分类: location
get_terms_by_post_type("worker", "location");
Is there WordPress build-in function for that?是否有 WordPress 内置功能? All solutions what I found are custom functions with sql query.
我发现的所有解决方案都是带有 sql 查询的自定义函数。
If the location
custom taxonomy is only registered for the worker
post type then you can use the get_terms function to get all the terms:如果
location
自定义分类法仅针对worker
帖子类型注册,那么您可以使用 get_terms 函数获取所有术语:
$terms = get_terms('location', array('hide_empty' => false));
If the taxonomy is used on multiple post types, and you want to get just the terms used on a certain post type then you will need a custom query for that.如果分类用于多种帖子类型,并且您只想获取用于特定帖子类型的术语,那么您将需要一个自定义查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.