Making internal rest requests non-blocking?

rest_do_request does not make a HTTP request to the REST API. rest_do_request handles a request object directly. WP_REST_Request and rest_do_request are for handling requests, not making them. This is why your attempt to make it non-blocking failed. If you want to make a non-blocking request to the REST API, you have to make a HTTP … Read more

Simple WordPress endpoint route doesn’t work

Exact namespace prefix and non-empty endpoint name helped me: add_action(‘rest_api_init’, function () { register_rest_route(‘vku/notifications’, ‘test’, [ ‘methods’ => ‘GET’, ‘callback’ => function (WP_REST_Request $request) { error_log(‘Route “notifications” works’); return new WP_REST_Response(true, 200); }, ]); });

Query_vars support in Rest API

correct me, if i’m wrong, but query vars are not processed in REST requests. but there is other ways to make this work. not really sure, if this will help with your problem but hopefully it is at least a push in the right direction function so380236_rest_cpt_query($args, $request) { $query_params = $request->get_query_params(); if (!array_key_exists(‘city’, $query_params)) … Read more

How to get data from /wp-json/wp/v2/users/me

I was just doing this earlier, if you are trying to simply get user data from your wordpress website with Postman just simply do a request to: /wp-json/wp/v2/users/ or directly to your user number: /wp-json/wp/v2/users/User Number here (you will need ACF to REST API plugin ) so you can see the endpoint acf field below … Read more

How to make a fetch() POST request to wordpress rest api?

‘X-WP-Nonce’ : Ajax.nonce Was missing that’s why it was giving the error fetch(‘https://mywebsite.online/wp-json/wp/v2/code’, { method: ‘POST’, credentials: ‘same-origin’, headers: new Headers({ ‘Content-Type’: ‘application/json;charset=UTF-8’, ‘X-WP-Nonce’ : Ajax.nonce }), body: JSON.stringify(OurPostData), }).then(response => { console.log(response); return response.json(); });

Sidebar endpoint using WordPress API

Is there a default endpoint for sidebars? No, I don’t think there is. So (for now), using a custom REST API endpoint does sound like a good option to me. gives me the sidebar not in json format and then a json response with an empty body_response That’s because get_sidebar() echo the output, hence the … Read more

Custom WP API endpoint NULL body data

I have solved the issue. It was unrelated to json / javascript / api. It was a simple issue of tmp folder ownership. Since there were no errors spewing out by the php managing the request, I never noticed a PHP NOTICE saying to check permissions in temp folder as php was unable to upload … Read more

Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)

Looks like it might be your WPML. See here: https://wpml.org/forums/topic/wpml-add-rewritebase-en-in-htaccess/ For posterity, the summary of this page is as follows: Problem: Some wrong settings caused an issue with “Use directory for default language”. A 500 error was showing. Solution: The client reports here that pressing the ‘Reset Settings’ button in WPML -> Languages probably solved … Read more