admin-ajax.php slow, how to speed it up?

Ajax endpoint is known to be relatively slow, but that primarily comes from loading WordPress core. If you are seeing drastic difference between two endpoints (native Ajax vs yours custom) that both perform core load, then something is doing something that degrades Ajax endpoint on top of it. I would profile Ajax endpoint to have … Read more

Category Ajax call

You could try to use the .children method to filter through your response – let’s say the posts are comming in containers with a particular selector on them – say, you add class=”mypost” on the divs when you build the response -, then you can do something like this in your success method: // … … Read more

Placement of add_action() for ajax callback?

When you send an AJAX request, wp-admin/admin-ajax.php is called, not your template file. This separate request has no knowledge of all existing code in all existing templates, because they aren’t even included. What is included: the theme’s functions.php and plugin files. This is why your callback works in a plugin. As a rule of thumb: … Read more

I have to post data by AJAX in wordpress to another Website

This will not work due to the “same-origin policy” unless that server you are trying to reach specifically allows these type of requests with something like Access-Control-Allow-Origin: *. You can read the documentation on MDN in order to get more information about this topic. From my tests, the server will also need another header configured … Read more