因此,我正在构建此post query数组:
$posts = get_posts(array(
\'author\' => $publisher_info-ID,
\'post_type\' => \'post\',
\'posts_per_page\' => 150,
\'meta_query\' => array(
array(
\'taxonomy\' => \'type\',
\'field\' => \'slug\',
\'terms\' => array( \'campaign\' ),
),
array(
\'key\' => \'status\',
\'value\' => \'active\',
),
),
\'orderby\' => \'rand\'
));
我正在努力的是如何集成两个元键比较?
假设我有两个元键meta_key
A1和meta_key
A2。
两者都有数字meta_value
.
我想要的是合并:A1<;阵列中的A2。
任何帮助都将不胜感激。
SO网友:MANOJ VASHIST
使用此类型的代码:
$args = array(
\'author\' => $publisher_info->ID,
\'post_type\' => \'post\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'type\',
\'field\' => \'slug\',
\'terms\' => array( \'campaign\' ),
)
),
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'status\',
\'value\' => \'active\',
\'compare\' => \'=\'),
array(
\'key\' => \'B\',
\'value\' => \'1\',
\'compare\' => \'!=\')
)
);
$data = new WP_Query($args);