I'd like to list the taxonomy terms within my shortcode.
This is how I get the list of terms (separated by commas):
<?php $terms = get_the_terms( $post->ID , array( 'shoptype' ) );
$i = 1;
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, array( 'shoptype' ) );
if( is_wp_error( $term_link ) )
continue;
echo '' . $term->name . '';
echo ($i < count($terms))? ", " : "";
$i++;
} ?>
But I am trying to apply this to the following code (taxonomy_terms="' . $term->slug . '"), however it just keeps repeating the shortcode for each term:
<?php $terms = get_the_terms( $post->ID , 'shoptype' );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'shoptype' );
if( is_wp_error( $term_link ) )
continue;
echo do_shortcode( '[ajax_load_more post_type="shops" taxonomy="shoptype" taxonomy_terms="' . $term->slug . '" taxonomy_operator="IN" posts_per_page="9" button_loading_label="Loading Shops" button_label="View More" scroll="false" repeater="default" orderby="title" order="ASC"]' );
}
?>
Is there a way to list the terms (separated by commas) in the taxonomy_terms="" section?