Tutorials WordPress How to List All the Categories for Custom Post Type

How to List All the Categories for Custom Post Type

If you just want to list the custom post categories (taxonomies), then you can use the get_terms function.

The get_the_terms filter will be called when the cache has the term and will pass the found term along with the array of $taxonomies and array of $args.

<?php $taxonomy = 'books'; ?>
<?php $terms = get_the_terms($post_id, $taxonomy);?>
<?php if ($terms && !is_wp_error($terms)) : ?>
    <div class="tagcloud">
        <?php foreach ($terms as $term): ?>
            <a href="<?php echo get_term_link($term->slug, $taxonomy) ?>"><?php echo $term->name ?></a>
        <?php endforeach; ?>
    </div>
<?php endif;?>
Total
0
Shares
guest
0 Comments
Inline Feedbacks
View all comments
Previous Post

Getting Started with Designable User Interface iOS 9

Next Post
Wordpress Tutorials

Limit Archive Page Content with Read More Link in WordPress

Related Posts
By clicking “Allow All”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts. Cookie Notice
Allow All
0
Would love your thoughts, please comment.x
()
x