WP Remote Request not returning all of content via request
WP Remote Request not returning all of content via request
WP Remote Request not returning all of content via request
Rest API code to get ID of current user not working: get_current_user_id() gives 0
Cannot add custom field to “orderby” parameter in Rest API
Is there builtin way to use protected AJAX endpoint?
Yes, it’s surely possible, but not out-of-the-box. I.e. There’s no such REST query parameter in the WordPress core, but you can add it to your REST API request, e.g. via the URL query string, and then use the rest_<post type>_query hook which “Filters WP_Query arguments when querying posts via the REST API” and “Enables adding … Read more
How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
This is how I solved similar issue using validate callback – this is the part of code where bar argument is defined: ‘bar’ => array( ‘default’ => FALSE, ‘validate_callback’ => function($param, $request, $key) { if ($request[‘foo’] == 3) return ($param !== FALSE); return FALSE; } ), The default parameter causes call of validate callback even … Read more
How do I get reusable blocks via frontend REST API? We need to be logged in as a user and additionally add the wp_rest nonce to the block rest endpoint request, either via the _wpnonce POST/GET parameter or via the X-WP-Nonce header. See e.g. the docs for more information on the authentication. EDIT: As pointed … Read more
Essentially, you shouldn’t wrap your REST route declarations inside is_admin() since WordPress will not load them (see @DarkNueron comment). What you can do is pass a ‘permission_callback’ function to the register_rest_route function. If the function returns true, the request is allowed to continue; if false, an error is returned. So you could do: register_rest_route(‘your-namespace/v1’, ‘/options/’, … Read more
What would be the best way to implement Magic Link logins in WordPress?