2
デフォルトのwp rest api V2エンドポイントを複製するにはどうすればよいですか?私は、デフォルトのエンドポイントと経路をそのまま維持したいが、私のアプリケーションに単純な応答を使用したい。デフォルトのWP REST API(v2)エンドポイントの重複
WordpressのV4.7
今の私のコード:また http://localhost/wp/wp-json/myrest/
、(/ myrest)私の名前空間http://localhost/wp/wp-json/
リストを呼び出す
function register_custom_routes()
{
$controller = new MY_REST_Posts_Controller;
$controller->register_routes();
}
add_action('rest_api_init', 'register_custom_routes', 1);
class MY_REST_Posts_Controller extends WP_REST_Controller {
// this is a copy of default class WP_REST_Posts_Controller
}
は私を与える:
{
"namespace": "myrest",
"routes": {
"/myrest": {
"namespace": "myrest",
"methods": [
"GET"
],
...
"/myrest/(?P<id>[\\d]+)": {
"namespace": "myrest",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
...
}
けどhttp://localhost/wp/wp-json/myrest/posts
(デフォルトのapiルートコールのような)の投稿をリストしようとすると動作しません:
{
"code": "rest_no_route",
"message": "No route was found matching the URL and request method",
"data": {
"status": 404
}
}
アンドロイドアプリの簡易版を入手する必要がありますが、デフォルトの休憩のエンドポイントと経路をそのまま維持したいと考えています。
解決方法を見つけましたか?私は同じものを探しています。 –
解決策は見つかりましたか? –