arrays - Wordpress Taxonomy Term not accepting dymanic varialble -
i have code.
$activity = 79, 71, 78, 74, 77, 76, 75, 73;
is working
$args = array( 'orderby' => 'rand', 'showposts' => '-1', 'post_type' => 'packages', 'tax_query' => array( 'relation' => 'and', array( 'taxonomy' => "activity", 'terms' => array(79, 71, 78, 74, 77, 76, 75, 73), // working 'field' => 'id' ), array( 'taxonomy' => "destination", 'terms' => "$destination", 'field' => 'id' ) ) ); $query = new wp_query( $args ); if($query->have_posts() ) : ?>
is not working
$args = array( 'orderby' => 'rand', 'showposts' => '-1', 'post_type' => 'packages', 'tax_query' => array( 'relation' => 'and', array( 'taxonomy' => "activity", 'terms' => array($activity), // variable not working 'field' => 'id' ), array( 'taxonomy' => "destination", 'terms' => "$destination", 'field' => 'id' ) ) ); $query = new wp_query( $args ); if($query->have_posts() ) : ?>
when set variable within array deesnot work. can has sugestion ??
set:
$activity = array(79, 71, 78, 74, 77, 76, 75, 73);
then can use:
'terms' => $activity,
arrays wordpress taxonomy
No comments:
Post a Comment