WordPress as a CMS – best way to decouple publishing/front-end

To disable WP frontend and WP REST API output, create an empty theme, i.e. ‘My Empty Theme’ in /wp-content/themes/myemptytheme/, that contains 3 files:

  • style.css
  • index.php
  • functions.php

style.css may contain the theme name only:

/*
Theme Name: My Empty Theme
*/

index.php – leave it empty

functions.php – include the following code to disable REST API output:

<?php
   add_filter( 'rest_authentication_errors', 'no_rest_api' );
   function no_rest_api( $result ) {
          return new WP_Error( 'no_rest_api', 'Rest API disabled', array( 'status' => rest_authorization_required_code()));
   }
?>

When you query a REST API endpoint, the response will be:

{
  "code": "no_rest_api",
  "message": "Rest API disabled",
  "data": {
     "status": 403
  }
}

Remember to switch to the new theme after creating the theme files.

techhipbettruvabetnorabahisbahis forumutaraftarium24edueduseduedueduseduseduseduseduedu