我需要使用自定义元动态更改分类术语。下面是我从哪里开始......对我来说有意义,但不起作用。
<?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();
?>
改变
'terms' => '$dynamic'
到
'terms' => $dynamic
PHP 不会替换单引号内的变量。