特定のカスタム投稿のIDのみ文字列にする関数
$args_rooms = array( 'post_type' => 'rooms', //カスタム投稿タイプの指定 'post_status' => array('publish'), 'posts_per_page' => -1, ); $room_posts = get_posts($args_rooms); $room_ids = array(); foreach ($room_posts as $room_post){ $room_ids[] = $room_post->ID; } $room_ids_string = implode(",", $room_ids); //IDの文字列