apiFetch security

This all works perfectly, but it seems too easy. Should I be passing a nonce along somewhere? No It seems like apiFetch has some middlewares that include a nonce – is this all done for us by default? Yes. If your endpoint requires a nonce and apiFetch did not provide it, then apiFetch would not … Read more

Build on same WordPress or different install?

I’ve decided that I will do this new function as a custom post type in the same installation as the college website. I will find another project to learn and use WP Rest API. It’s an overkill to use WP Rest API on this project. I also realize that Our Team content is really part … Read more

Rest API Custom Endpoint with space character

You can do this like this: function get_custom_search_callback($request) { //$parameters = $request->get_params(); $response = urldecode($request->get_param(‘search’)); return rest_ensure_response($response); } add_action(‘rest_api_init’, ‘add_custom_users_api’); function add_custom_users_api(){ register_rest_route(‘namespace/v1’, ‘custom-search/(?P<search>([a-zA-Z]|%20)+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘get_custom_search_callback’ ) ); } Note two things: you have to add %20 to the matched character set you have to urldecode() the search variable value … Read more

Query the REST API for a Tag by slug

I was looking at this before… Here is what I found (about 7 months old from today 3/21/2018.) The “correct” way to do this with the REST API is to get the IDs of each of those tags, then make the request using the ?tags= parameter: assuming “clicks” has ID 1, and “passes” has ID … Read more