Support » Developing with WordPress » How to display custom taxonomy for CPT

  • Resolved kirasiris


    So here I am again.

    I’ve been trying to figure out how to display tags(custom taxonomy) for my CPT for each single post that I create in the said CPT.

    So I tried this which is how I wanted them to be displayed:

                    <!-- Tags -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h1 class="panel-title"><i class="fa fa-tags" aria-hidden="true"></i> Tags</h1>
                        <div class="panel-body">
                            $tags_movie = get_the_terms( get_the_ID(), 'tags_movie');
                            foreach($tags_movie as $term){
                                echo '<a href="'. $term->slug .'"><span class="label label-success">'. $term->name .'</span></a>';

    the problem is that when clicking on them, instead of taking me to the archive.php file it takes me not a 404 error page.

    Maybe this caused by the way in which I have the permalinks set:


    Example of actual CPT without clicking at any tag:


    Example of actual CPT after clicking any tag:


    As I said instead of taking me to the archive file, it takes me to 404 error page and the url never changes as it supposed.

    Thanks in advance.

    NOTE in case you neeed them to see them without the pile of code:
    here is how I register the CPT:

    here is how I registered the taxonomy for the tags for the peliculas CPT:

Viewing 1 replies (of 1 total)
  • Thread Starter kirasiris


    I solved it.

                        global $post;
                        $terms = wp_get_post_terms($post->ID, 'tags_movie');
                        if ($terms) {
                            $output = array();
                            foreach ($terms as $term) {
                                $output[] = '<a href="' .get_term_link( $term->slug, 'tags_movie') .'">' .$term->name .'</a>';
                            echo join( ', ', $output );
Viewing 1 replies (of 1 total)
  • The topic ‘How to display custom taxonomy for CPT’ is closed to new replies.