我有我的单一财产。php显示自定义帖子类型“property”,在此页面中,我还想显示属于属性作者的自定义帖子类型“agent”,每个作者只有一个自定义帖子类型“agent”的帖子。
我想应该是这样的,单一财产。php使用查询显示自定义帖子类型“property”,从第一个查询中获取author,然后运行第二个查询,显示同一作者的自定义帖子类型“author”的所有帖子。
谢谢
我有我的单一财产。php显示自定义帖子类型“property”,在此页面中,我还想显示属于属性作者的自定义帖子类型“agent”,每个作者只有一个自定义帖子类型“agent”的帖子。
我想应该是这样的,单一财产。php使用查询显示自定义帖子类型“property”,从第一个查询中获取author,然后运行第二个查询,显示同一作者的自定义帖子类型“author”的所有帖子。
谢谢
您可以使用$post->post_author
,
所以在循环添加之前$agent = \'\';
然后在循环内添加
$agent = $post->post_author;
$agent_query = NEW WP_Query(array(\'post_type\' => \'agent\', \'author\' => $agent));
while ($agent_query->have_posts()){
$agent_query->the_post();
//do your agent loop here
}
wp_reset_postdata();