我将使用如下自定义查询:
$amsterdamstore_args = array(
\'post_type\' => \'store\', // This is your custom post type
\'tax_query\' => array(
array(
\'taxonomy\' => \'city\', // This is your custom taxonomy
\'terms\' => \'Amsterdam\', // The term you search for
\'field\' => \'name\', // Check against the term\'s name (you might use \'slug\', too)
)
),
\'meta_query\' => array(
\'relation\' => \'AND\', // you could use OR, too - depending on what you want
array(
\'key\' => \'store_postal_code\', // Here goes your post_meta field\'s key
\'value\' => \'1234AB\', // Here goes your post_meta field\'s value
\'compare\' => \'=\',
),
array(
\'key\' => \'store_parking\', // Here goes your post_meta field\'s key
\'value\' => \'SOME_VALUE\', // Here goes your post_meta field\'s value
\'compare\' => \'=\',
),
)
);
这些就是你需要的论点
WP_Query 或者-如果这对你更有用-
get_posts. - 循环查看结果,按正常方式获取\\u post\\u meta,然后就可以了。
顺便说一句:你可以根据自己的喜好组合meta_查询数组:添加一些,留下一些,你甚至可以嵌套得更深,做一些像and(A或B)(C或D)。。。