\d+)', array( 'methods' => 'GET', 'callback' => 'get_questions_posts_per_thematique_id', 'args' => array( 'excluded_ids' => array( 'sanitize_callback' => 'sanitize_text_field', ), ), )); }); function get_questions_posts_per_thematique_id($request) { $excluded_ids = $request->get_param('excluded_ids'); $excludedArray = explode(',', $excluded_ids); $id = $request['id']; $args = array( // "exclude" => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), "post_type" => "questions", "posts_per_page" => -1, "post__not_in" => $excludedArray, 'tax_query' => array( array( 'taxonomy' => 'thematiques', 'field' => 'term_id', 'terms' => $id ) ) ); $postDatas = get_posts($args); $response = new WP_REST_Response($postDatas); $response->set_status(200); return $response; }