0
votes

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);

?>
2

2 Answers

2
votes

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

0
votes

I think you will want to use this function and pass the custom post type as a parameter.

$taxonomies=get_object_taxonomies('arts');