WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Cannot display the categories under my custom taxonomy (3 posts)

  1. markyeoj
    Member
    Posted 1 year ago #

    I have a problem here, using the plugin I registered a custom post type and I named it 'recipe' then I created a custom taxonomy under the post type, I named it 'recipe category'. Now I want to display the of categories under that custom taxonomy, but unfortunately I have no luck.

    I tried this code

    <?php
    
    $taxonomy = 'recipecategory';
    $tax_terms = get_terms($taxonomy);
    ?>
    <ul>
    <?php
    foreach ($tax_terms as $tax_term) {
    echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
    }
    ?>
    </ul>

    http://wordpress.org/extend/plugins/custom-post-type-ui/

  2. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    Have you created any CPT posts that use it yet? get_terms() hides empty terms by default, so if you have none yet, it won't show anything.

    http://codex.wordpress.org/Function_Reference/get_terms

  3. markyeoj
    Member
    Posted 1 year ago #

    Ouch, this is very embarrassing.. why i didn't think of that? Thanks @Michael.. great relief.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic