diff --git a/inc/template-tags/print-post-taxonomies.php b/inc/template-tags/print-post-taxonomies.php new file mode 100644 index 000000000..126a57707 --- /dev/null +++ b/inc/template-tags/print-post-taxonomies.php @@ -0,0 +1,63 @@ + '', + 'post_id' => get_the_ID(), + 'linked' => true, + 'in_list' => true, + ]; + + // Parse args. + $args = wp_parse_args( $args, $defaults ); + + // Bail early if we have no post id or taxonomy name. + if ( empty( $args['post_id'] ) || empty( $args['tax_name'] ) ) : + return; + endif; + + // Get the terms. + $wd_s_terms = get_the_terms( $args['post_id'], $args['tax_name'] ); + + // Set up the display. + $wd_s_tagname = $args['in_list'] ? 'ul' : 'span'; + ?> + + < class="post-taxonomies"> + ' : '' ); + if ( $args['linked'] ) : + print_element( + 'anchor', + [ + 'text' => $wd_s_term->name, + 'href' => get_term_link( $wd_s_term->term_id, $args['tax_name'] ), + ] + ); + else : + echo esc_html( $wd_s_term->name ); + endif; + echo $args['in_list'] ? '' : ''; + endforeach; + ?> + > + +