I'm a newbie in WordPress. I have created a custom post type called arts
and custom taxonomies called male
, female
and children
for arts
. Is there a way I could list only the taxonomies under the post type arts
? I have tried using get_taxonomies();
but it produces all the taxonomies but I want only taxonomies under arts
. My code is here. Thanks.
<?php $taxonomies=get_taxonomies();
var_dump($taxonomies);
?>
Let me know if this works for u --
<?php
$args=array(
'name' => 'arts'
);
$output = 'objects'; // or objects
$taxonomies=get_taxonomies($args,$output);
if ($taxonomies) {
foreach ($taxonomies as $taxonomy ) {
echo '<p>' . $taxonomy->name . '</p>';
}
}
?>
Reference - Source
我想你会想要使用这个函数并将自定义帖子类型作为参数传递。
$taxonomies=get_object_taxonomies('arts');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.