Black Friday Black FridayUp to 85% off all WP Ghost plans.48 months from $49, or pay once for lifetime. SHOP NOW

How Do I Change admin-ajax.php in WordPress?

Moved

This tutorial has moved to the new WP Ghost Knowledge Base where each feature is presented in detail.

View on new site

Go to WP Ghost > Change Paths > Ajax Security, enter a name in Custom admin-ajax Path and click Save. Your pages then call the new path instead of /wp-admin/admin-ajax.php, so the source no longer points bots to it.

Why changing admin-ajax.php matters

The /wp-admin/admin-ajax.php file is one of the most targeted endpoints in WordPress. Every AJAX request on the frontend (form submissions, live search, add-to-cart actions, infinite scroll) passes through this single file. Bots exploit it in several ways: they send crafted POST requests with malicious action parameters to trigger vulnerabilities in plugins, they use it for SQL injection attempts, and they probe it to confirm a site runs WordPress since admin-ajax.php only exists in WordPress installations.

Changing the admin-ajax.php path takes this well-known endpoint out of your page source, so bots reading your pages don’t see it. Your AJAX features keep working through the new URL without code changes. The default file still answers, because the WordPress dashboard uses it.

How to change admin-ajax.php in WP Ghost

Go to WP Ghost > Change Paths > Ajax Security. Enter a name in the Custom admin-ajax Path field. Pick something unique that’s hard to guess, like app-handler or a random string. Click Save.

After saving, WP Ghost rewrites the frontend AJAX URLs to your custom path. Switch on Hide wp-admin from Ajax URL as well and the /wp-admin/ part goes too: with app-handler as the path, frontend AJAX calls use /app-handler instead of /wp-admin/admin-ajax.php.

Clear all cache after making this change so cached pages use the new AJAX URL. Test your site’s AJAX-dependent features (forms, live search, WooCommerce add-to-cart) in a private browser to confirm everything works. For the complete AJAX configuration guide, see the Change admin-ajax.php Path tutorial.

Compatibility notes

Most plugins and themes keep working with a custom admin-ajax.php path because WP Ghost handles the URL rewriting at the server level. However, a few plugins hardcode the default admin-ajax.php path instead of using WordPress’s admin_url('admin-ajax.php') function. If a specific feature stops working after changing the AJAX path, that plugin likely hardcodes the URL.

In that case you have two options: set the AJAX path back to the default admin-ajax.php in WP Ghost and keep the other path changes, or ask the plugin author to use the standard WordPress AJAX URL function. WP Ghost’s other protection (path changes, firewall, brute force protection, security headers) keeps working whatever the AJAX path is.

Frequently asked questions

Will changing admin-ajax.php break WooCommerce?

No. WooCommerce uses WordPress’s standard AJAX URL function, so it automatically uses the new path. Add-to-cart, checkout, coupon application, and all other WooCommerce AJAX features work normally. Clear your cache after making the change and test the cart in a private browser.

Does Ghost Mode change admin-ajax.php automatically?

Yes. Ghost Mode sets a custom admin-ajax path (ajax-call) and switches on Hide wp-admin from Ajax URL, along with the other path changes. You can keep that name or change it. Safe Mode leaves the AJAX path at its default to keep compatibility high.

Is this a free feature?

Yes. Changing the admin-ajax.php path is included in the free version of WP Ghost.

Does WP Ghost modify WordPress core files?

No. The admin-ajax.php file is not renamed, moved, or modified. WP Ghost uses server rewrite rules to route requests from the new URL to the original file. Deactivating WP Ghost restores the default AJAX path instantly.