我正在尝试使用后端的自定义字段在前端的类别归档的WP\\U查询中设置分类法。
在页面模板中。这将从自定义字段中获取我的类别:
$terms = get_field(\'add_categories_custom_template\', $term->term_id);
if( $terms ):
foreach( $terms as $term ): 
echo $term; echo \',\';
endforeach; 
endif; 
 这给了我如下输出:
12,345,900,
但我如何将输出输入到
\'terms\' => array 对于
tax_query? 我需要的是以这种方式输出的ID数组:
\'tax_query\' => array(
        array(
            \'taxonomy\'  => \'product_cat\',
            \'field\'     => \'term_id\',
            \'terms\'     => array(\'12,345,900\'),  // output this way
            \'operator\'  => \'IN\',
        )
   )
 但是这样做
$terms = get_field(\'add_categories_custom_template\', $term->term_id);
if( $terms ):
foreach( $terms as $term ): 
$my_terms = $term; echo \',\';
endforeach; 
endif; 
 还有这个
\'tax_query\' => array(
        array(
            \'taxonomy\'  => \'product_cat\',
            \'field\'     => \'term_id\',
            \'terms\' => array($my_terms),
            \'operator\'  => \'IN\',
        )
   )
 仅输出第一个$期限(即12),而不输出后续期限(345和900)。