Query_post($args)

时间:2011-10-21 作者:Arzt Öffnungszeiten

是否可以通过此查询使用数组?

此版本不起作用:$args=数组(\'顺序\'=>\'ASC\',
>\'meta\\u key=>数组(\'city\\u 1\',\'city\\u 2),
>\'meta\\u value\'=>数组(\'NY\',\'LA\')


query\\u posts($args)
---------



此版本有效:


$args=数组(
“order”=>“ASC”,
“meta\\u key=>“city\\u 1”,
“meta\\u value”=>“LA”)

query\\u posts($args)
---------

有人有主意吗
谢谢

1 个回复
SO网友:Milo

Refer to multiple custom field handling in WP_Query:

$args = array(
    \'meta_query\' => array(
        \'relation\' => \'OR\',
        array(
            \'key\' => \'city_1\',
            \'value\' => array(\'NY\',\'LA\'),
            \'compare\' => \'IN\'
        ),
        array(
            \'key\' => \'city_2\',
            \'value\' => array(\'NY\',\'LA\'),
            \'compare\' => \'IN\'
        )
    )
);
query_posts($args);
结束

相关推荐