Output assigned custom taxonomy to custom post type

this is output

I created a custom post type called “capitulo” and custom taxonomy called “serie” and i wanna output asigned taxonomy to custom post with link.

Here is my code

                            <?php //Do something if a specific array value exists within a post

                        $term_list = wp_get_post_terms($post->ID, 'serie', array("fields" => "all"));

                        $terms = get_terms( 'serie' );

                        foreach ( $terms as $term ) {

                            // The $term is an object, so we don't need to specify the $taxonomy.
                            $term_link = get_term_link( $term );

                            // If there was an error, continue to the next term.
                            if ( is_wp_error( $term_link ) ) {
                                continue;
                            }

                            // Then you can run a foreach loop to show the taxonomy terms infront.
                            foreach ( $term_list as $term_single ) {

                                echo '<h2><a href="' . esc_url( $term_link ) . '">' . $term_single->name . '</a></h2>';

                            } 
                        }

                        ?>

it output a link to all taxonomy terms with link for all custom post. Look

Read more here:: Output assigned custom taxonomy to custom post type

Leave a Reply

Your email address will not be published. Required fields are marked *