2

I have created three custom taxonomies that categorize my post types by project-client, project-brand, & project-medium. As of now I can use the get_the_terms() function to return only one taxonomy successfully, project-client.

Is there a way to use get_the_terms() to show taxonomies from all three custom taxonomies or is a different function needed such as get_terms()?

My code as it stands:

<?php
$project_attrs = get_the_terms( $post->ID, 'project-client' );
if (!empty($project_attrs)){ ?>
    <ul class="meta">
        <?php 
        foreach($project_attrs as $attr){
        echo '<li>' . $attr->name . ' ' . '/' . '</li>';
        }    
        ?>
    </ul>
<?php } ?>

The function is successful at displaying my requested taxonomy, just would like to know how to display all taxonomies from multiple custom taxonomies.

2
  • You can get all the registered taxonomies with get_taxonomies(), then loop over that to get all the terms from all the taxonomies.
    – Pat J
    Commented Oct 5, 2016 at 14:28
  • @Pat J Looked at get_taxonomies and it would give me the taxes of all public taxonomies so I continued reading up and managed to create an array of taxonomies to get the result I needed. Your comment helped me go in the right direction. Thank you. Here is the final code for reference: pastebin.com/N70ZABYV
    – WeebleWobb
    Commented Oct 7, 2016 at 15:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.