The do_shortcode()
function is currently in the foreach loop. I don’t know what are the parameters of this shortcode , but if it accepts comma separated values of term slugs:
$terms = get_the_terms( $post->ID , 'shoptype' );
$i=1;
$commaSeparatedvalues="";
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, 'shoptype' );
if( is_wp_error( $term_link ) )
continue;
$commaSeparatedvalues .= $term->slug;
$commaSeparatedvalues .= $i < count($terms) ? ", " : "";
$i++;
}
echo do_shortcode( '[ajax_load_more post_type="shops" taxonomy="shoptype" taxonomy_terms="' . $commaSeparatedvalues . '" taxonomy_operator="IN" posts_per_page="9" button_loading_label="Loading Shops" button_label="View More" scroll="false" repeater="default" orderby="title" order="ASC"]' );
So basically build the comma separated string in the foreach
and keep the do_shortcode()
function out of the foreach loop