0
votes

I need to dynamically change the taxonomy term using custom meta. Below is where I've been starting from... makes sense to me but doesn't work.

<?php
$dynamic = rwmb_meta( $post->ID, blr_queryslug, true );


$args = array(
'posts_per_page' => -1,
'tax_query' => array(
    'relation' => 'AND',
    array(
        'taxonomy' => 'product_cat',
        'field' => 'slug',
        'terms' => 'music'
    ),
    array(
        'taxonomy' => 'product_cat',
        'field' => 'slug',
        'terms' => '$dynamic'
    )
    ),
    'post_type' => 'product'
  );
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) {
$the_query->the_post();
woocommerce_get_template_part( 'content', 'product' );
}
wp_reset_postdata();
?>
1

1 Answers

0
votes

Change

    'terms' => '$dynamic'

to

    'terms' => $dynamic

PHP does not replace variables inside single quotes.