How to stop WP API endpoint from caching?
If you have access to your request header you can add the line. Cache-Control: private or Cache-Control: no-cache. This will force well-behaved hosts to send you fresh results.
If you have access to your request header you can add the line. Cache-Control: private or Cache-Control: no-cache. This will force well-behaved hosts to send you fresh results.
I made a shortcut to my image by adding it directly to the API response. //Add in functions.php, this hook is for my ‘regions’ post type add_action( ‘rest_api_init’, ‘create_api_posts_meta_field’ ); function create_api_posts_meta_field() { register_rest_field( ‘regions’, ‘group’, array( ‘get_callback’ => ‘get_post_meta_for_api’, ‘schema’ => null, ) ); } //Use the post ID to query the image and … Read more
permalinks with get variables
The way you are going about it is wrong. The source of data should not be relevant to how you store it in the DB. If the fact that this is a 3rd party service that supplies the data in some buzzword format confuses you, maybe you should try to imagine the input as coming … Read more
“The REST API uses JSON exclusively as the request and response format, including error responses.” — WordPress REST API Reference I would try explicitly setting the content type/length and json encode your data with something like this (assuming you need to specify all the options you did in your code provided): $data = array( ‘title’ … Read more
I assume that your custom dashboard is on a different domain/subdomain than the WordPress installation. Cookies can only be set for the current domain. Typically cookies will not work cross domain. So your dashboard cannot create a cookie for the WordPress website. Theoretically it’s possible to bypass with some server configurations, but this technique has … Read more
I know it’s a bit far fetched, but might help. For anyone looking for WP REST API implementation with JWT, here’s our solution. Add it to your function.php add_action(‘rest_api_init’, ‘wp_rest_user_endpoints’); /** * Register a new user * * @param WP_REST_Request $request Full details about the request. * @return array $args. **/ function wp_rest_user_endpoints($request) { /** … Read more
Looks like I found a snippet that do exactly that. It’s from Daniel Bachhuber, the API developer. add_filter( ‘rest_authentication_errors’, function( $result ) { if ( ! empty( $result ) ) { return $result; } if ( ! is_user_logged_in() ) { return new WP_Error( ‘restx_logged_out’, ‘Sorry, you must be logged in to make a request.’, array( … Read more
I think the query parameter that you want for post status is: status=draft Let me know if this doesn’t work.
I was able to get this working after a bit of fiddling. Give the #map-canvas element a height (you can do this in CSS): <div id=”map-canvas” style=”height:500px”></div> Add the callback argument to the google-maps script URL and add the defer and async attributes to the google-maps script tag. Also make custom-scripts a dependency for google-maps: … Read more