Admin Ajax
Quick Definition
Admin Ajax (admin-ajax.php) is the file WordPress uses to process all AJAX requests — background data exchanges between your browser and the server without reloading the page.

What Is Admin Ajax?
Admin Ajax refers to the wp-admin/admin-ajax.php file — the central endpoint that WordPress uses to handle all AJAX (Asynchronous JavaScript and XML) requests. AJAX lets your browser exchange data with the server in the background without reloading the entire page. Every time you see something update on a WordPress site without a full page refresh — like an infinite scroll, a live search, or an add-to-cart button — there is a good chance admin-ajax.php is involved.
Here is how it works:
- JavaScript on the page sends a POST request to
admin-ajax.phpwith anactionparameter (e.g.,action: "load_more_posts") - WordPress receives the request and looks for a matching hook:
wp_ajax_load_more_posts(for logged-in users) orwp_ajax_nopriv_load_more_posts(for visitors) - The PHP function attached to that hook runs, processes the data, and returns a response (usually JSON)
- JavaScript receives the response and updates the page without reloading
Two hooks handle every AJAX request:
wp_ajax_{action}— Fires only for logged-in userswp_ajax_nopriv_{action}— Fires for non-logged-in visitors (public-facing AJAX)
If you only hook into wp_ajax_, your AJAX will work for admins and editors but silently fail for regular visitors. Most front-end features need both hooks registered.
To pass the correct admin-ajax.php URL to JavaScript, developers use wp_localize_script(). You cannot hardcode the path because it varies between WordPress installations. Security is handled through nonces — tokens that verify the request came from a legitimate source and not a malicious third party.
Admin Ajax in Practice
Admin-ajax.php powers countless WordPress features: WooCommerce add-to-cart buttons, live search and filtering, comment submission without reload, dashboard widgets, and plugin settings that save without a page refresh. If you have ever seen admin-ajax.php in your browser's network tab or in a page speed report, that is a plugin or theme making background requests through this endpoint.
One common performance concern: admin-ajax.php loads a significant portion of the WordPress environment on every request. On high-traffic sites with plugins that make frequent AJAX calls, this can become a bottleneck. The modern alternative is the REST API, which is lighter, supports proper HTTP methods (GET, POST, PUT, DELETE), and returns clean JSON. Many newer plugins are migrating from admin-ajax.php to the REST API for better performance.
Why It Matters
Understanding admin-ajax.php helps you debug slow-loading pages (frequent AJAX calls show up in performance audits), troubleshoot plugins that fail silently on the front end (missing nopriv hooks), and make informed decisions about whether a plugin is using modern or legacy approaches. If you are developing for WordPress, knowing when to use admin-ajax.php versus the REST API is a fundamental skill.