我正在尝试为我的网站构建一个音乐播放器,我正在构建端点(Wordress REST API),这将允许我获取元值不为空的上一篇和下一篇文章(meta_val 是 soundcloud_id)我正在传递当前 ID播放器正在使用。我似乎无法弄清楚如何获得包含 soundcloud_id 的下一篇和上一篇文章。这是我目前所拥有的......
谢谢
$args = array(
'post_type' => 'track',
'posts_per_page'=>'1',
'p' => array($prevID),
'post_status' => "publish",
'offset'=> "-1",
'meta_query' => array(
array(
'key' => 'soundcloud_id',
'value' => ' ',
'compare' => '!=',
),
),
);
$posts_query = new WP_Query();
$query_result = $posts_query->query( $args );
$posts = array();
foreach ( $query_result as $post ) {
$post->soundcloud_id = get_field('soundcloud_id', $post->ID);
$posts[] = $post;
}
$response = new WP_REST_Response( $post );
$response->set_status( 200 );
return $response;