我正在从自定义元数据库获取帖子id数组。我试过了
$urls= get_post_meta( get_the_ID(), \'videos\', false );
foreach ( $urls as $url ) {
foreach ( $url[\'link\'] as $u ) {
$posts[] = $u;
}
$my_query = new WP_Query( array( \'post_type\' => \'slider\', \'post__in\' => $posts ) );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$my_query->the_post();
the_title();
}
}
wp_reset_postdata();
}
此循环查询选定的帖子id,但它们不是按id顺序排列的。它们是默认的ASC顺序。我尝试过的其他方法
$a=explode(" ",$u);
//$posts[]=$u;
$my_query = new WP_Query( array( \'post_type\' => \'slider\', \'post__in\' => $a ) );
这只显示数组中的最后一篇文章。在var转储上
string(2) "67" string(2) "77" //$u