我会这样做:
$args = array (
\'posts_per_page\' => 10,
\'order\' => \'DESC\'
);
$tax_query = array(\'relation\' => \'OR\');
for($i=0;$i<count($Tax),$i++){
array_push($tax_query, array(
\'taxonomy\' => $Tax[$i],
\'field\' => \'slug\',
\'terms\' => array( $Tag )
));
}
$args[\'tax_query\'] = $tax_query;
使用速记数组大括号可能更清晰:
$args = [
\'posts_per_page\' => 10,
\'order\' => \'DESC\'
];
$tax_query = [\'relation\' => \'OR\'];
for($i=0;$i<count($Tax),$i++){
$tax_query[] = [
\'taxonomy\' => $Tax[$i],
\'field\' => \'slug\',
\'terms\' => array( $Tag )
];
}
$args[\'tax_query\'] = $tax_query;