
Learn to Code Like a Pro in Just 10 Minutes (For WordPress Beginners)
By WPCodeBox
Learn how to disable XML-RPC in your WordPress site using code. This is done to enhance security and avoid attacks on your site.

XML-RPC was once useful in WordPress, but today it mostly creates security risks. Hackers use it to brute force logins or slow down sites.
To prevent this, you can disable XML-RPC with a simple snippet. Logged-out users will no longer be able to access the XML-RPC endpoint, and requests can be redirected to your homepage for extra security.
Below is the code snippet from the video used to disable XML-RPC:
add_filter('xmlrpc_enabled','__return_false');
add_action('init',function() {
if(strpos($_SERVER['REQUEST_URI'],'xmlrpc.php') !== false) {
wp_redirect(home_url());
exit;
}
});




