Created
July 2, 2020 15:56
-
-
Save nfsarmento/266086bbe4768c7aa7950b2c067bcd58 to your computer and use it in GitHub Desktop.
Display categories in single-cpt.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( is_singular('YOUR_CUSTOM_POST_TYPE') ) { | |
| $terms = get_the_terms($post->ID, 'custom_categories'); | |
| foreach ($terms as $term) { | |
| $term_link = get_term_link($term, 'custom_categories'); | |
| if (is_wp_error($term_link)) | |
| continue; | |
| echo '<a href="' . $term_link . '">' . $term->name . '</a>, '; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment