使用array puch将Array转换为query_posts数组

时间:2016-02-12 07:53:50

标签: php arrays wordpress custom-post-type term

我有这个数组

  array[] =  [brands-processors] => Array (
        [taxonomy] => product_cat
        [field] => id
        [terms] => 105,315
        [compare] => IN
        )
    [cpu-socket] => Array (
        [taxonomy] => product_cat
        [field] => id
        [terms] => 206
        [compare] => IN
        )
    [cpu-type] => Array (
        [taxonomy] => product_cat
        [field] => id
        [terms] => 219
        [compare] => IN
        )

但我想将其传递给元查询wordpress函数

'tax_query' => array(
    'relation' => 'OR',
    array(
        'key' => 'mykey',
        'value' => 'value1',
        'compare' => '='
    ),
    array(
        'key' => 'mykey',
        'value' => 'value2',
        'compare' => '='
    ),
)

我如何实现这一点,或者是其他任何方式,然后是array_puch

我试过但想要创建上面的结构

  'tax_query' => array(
        'relation' => 'OR',
    $myArray
    )

0 个答案:

没有答案