Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Plugin name: Caldera Terms shortcode
- */
- function caldera_terms_shortcode_callback( $atts ) {
- $atts = shortcode_atts(
- array(
- 'taxonomy' => '',
- 'post' => get_the_ID(),
- ),
- $atts,
- 'my_terms'
- );
- if ( ! empty( $atts[ 'taxonomy']) ) {
- $terms = wp_get_object_terms( get_the_ID(), $atts[ 'taxonomy' ] );
- $out = '<ul class="my-terms-shortcode-term-list ' . esc_attr( 'my-terms-shortcode-term-list-' . $atts[ 'taxonomy' ] ) .'">';
- foreach( $terms as $term ) {
- $out .= '<li><a href="' . get_term_link( $term->slug, $atts[ 'taxonomy' ] ) . '">' . esc_html( $term->name ) . '</a></li>';
- }
- $out .= '</ul>';
- return $out;
- }
- }
- add_shortcode( 'caldera_terms', 'caldera_terms_shortcode_callback' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement