Created
May 23, 2021 21:10
-
-
Save frankyonnetti/709e34e00a02bb76e634a1e6139d2c55 to your computer and use it in GitHub Desktop.
WordPress - Get terms from post #wordpress #taxonomy
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 | |
| // project_tag is the term parent | |
| <?php if (has_term($post->ID, 'project_tag')): ?> | |
| <div class="blog-focus-areas"> | |
| <h3>Related Focus Areas</h3> | |
| <?php echo get_the_term_list($post->ID, 'project_tag', '<ul><li>', ',</li><li>', '</li></ul>'); ?> | |
| </div> | |
| <?php endif; ?> | |
| -- or -- | |
| <?php $focus_areas = get_the_terms( $post->ID, 'project_tag' ); ?> | |
| <?php foreach ( $focus_areas as $focus_area ): ?> | |
| <?php echo get_the_term_list( $focus_area, 'project_tag', '', ', ' ); ?> | |
| <?php endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment