我需要一些帮助。我的目标是通过一系列邮政编码查询“诊所”邮政类型。然后获取这些诊所的ID,并运行另一个名为“clinicspromo”的帖子类型查询以获得这些结果。然后在循环中运行查询#3以再次检索与每个诊所宣传片相关的诊所信息。我已经完成了大部分工作,我只是在转换$ post-> ID的结果时遇到问题;以逗号分隔的ID数组,就像邮政编码列表一样。任何帮助,将不胜感激!获取ID的数组,然后通过这些ID查询不同的帖子类型
$zipcodelist = '90001, 90002, 90003';
$args = array(
'orderby' => 'post_title',
'order' => 'DESC',
'post_type' => 'clinics',
'meta_query' => array (
array (
'key' => 'cliniczipcode',
'value' => $zipcodelist,
'compare' => 'IN'
)
));
$postlist = get_posts($args);
$posts = array();
foreach ($postlist as $post) {
$posts[] += $post->ID;
}
$current = array_search(get_the_ID(), $posts);
$argstwo = array(
'orderby' => 'post_title',
'order' => 'DESC',
'post_type' => 'clinicpromos',
'meta_query' => array (
array (
'meta_key' => 'assignclinic',
'meta_value' => $current,
'compare' => 'IN'
)
));
$the_query = new WP_Query($argstwo);
让我们[继续这一讨论聊天](http://chat.stackoverflow.com/rooms/112225/讨论-间frayne-konok和-user2593040)。 –