Disable WordPress REST API

Posted

Code Preview

Comments


Easily disable the WP REST API on your website with this snippet.

<?php
add_filter("rest_authentication_errors", function ($access) {
    return new WP_Error(
        "rest_disabled",
        __("The WordPress REST API has been disabled."),
        [
            "status" => rest_authorization_required_code(),
        ]
    );
});
?>

Views: 9

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *