If I correctly guessed in the comment to your answer what you really want to do, then there are two options for solving this problem. The first is to develop your own API , as advised by your link, that is, the entry point for external request sources. But this is a rather cumbersome option that you hardly need.
The second is to simply accept some requests and send a response in response. In the previous answer, another user gave you a general working advice for such a decision, but, as for me, it would be more appropriate to proceed in the manner described below.
Mainly because specifically for asynchronous requests from plug-ins, and you probably have such a task, the functionality described below is suitable (it is in the Plugin API section), while the option proposed by another user is using the redirects functionality. which is completely wrong methodologically.
This functionality is tied to such a hook: wp_ajax_ (action) / wp_ajax_nopriv_ (action) . In short, it works out of the box for requests formed from the admin panel, and with a little magic applied it works for the front of the site. A detailed description of how to do this is here .
There are three key points here:
- Write a function that will make a
POST request to the address admin-ajax.php (the address will be used, including for the front). - Write a callback that will be used to catch your request and respond to it, which, in turn, hang up on this request using the mentioned
wp_ajax_(my_action) hook (some of the brackets change to your name). If the request needs to be done not only from the admin panel, then hang up the same callback using the wp_ajax_nopriv_(action) hook. - Add to the front
js object myajax (the name is arbitrary), in which you will store the address of your endpoint, the name of the request, the key to check the request to belong to your site ( wp_nonce , token, but this is not about your token, but about the token specifically for this functional) and other variables you need at the front.