所以你想要这些值108,78,90
对应ID为94的帖子的元键“区域”?
首先检索这些ID:
$the_post_id = 94;
$area_ids = get_post_meta( $the_post_id, \'areas\', false );
//Make sure they\'re all positive integers
$area_ids = array_map( \'absint\', $area_ids );
if( $area_ids ){
//We have IDs, retrieve posts
$areas = get_posts( array(
\'post_type\' => \'area\',
\'numberposts\' => -1,
\'post__in\' => $area_ids;
));
if( $areas ){
//We have areas
foreach( $areas as $area ){
echo get_the_title( $area ). \'<br/>\';
}
}
}
上述内容尚未得到验证,但在理论上应该是可行的。如果你愿意
$the_post_id
到当前正在查看的帖子的be ID,然后您可以使用
get_the_ID()
.