Forums

Give help. Get help.

  • # October 7, 2018 at 7:45 pm

    I have created custom post type, and also created some categories,
    Now the point is, i want to show the category name on the custom post type single page.

    Please provide me the code for showing the custom post type category on a single page.

    # October 8, 2018 at 3:48 am

    Try this for wp:

    <?php
    
    $taxonomy = 'your taxonom';
    $terms = get_terms($taxonomy); // Get all terms of a taxonomy
    
    if ( $terms && !is_wp_error( $terms ) ) :
    ?>
        <ul>
            <?php foreach ( $terms as $term ) { ?>
                <li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
            <?php } ?>
        </ul>
    <?php endif;?>
    
    ?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag