Home / Most Popular / Disable WordPress REST API
Duplicate Snippet

Embed Snippet on Your Site

Disable WordPress REST API

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

8.0k
Code Preview
php
<?php
add_filter(
	'rest_authentication_errors',
	function ( $access ) {
		return new WP_Error(
			'rest_disabled',
			__( 'The WordPress REST API has been disabled.' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);
	}
);

Comments

Add a Comment