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.
Related Posts:
- How do I represent ‘chunks’ of content within WordPress?
- Blog posts on one subdomain, pages on another
- How can I import users into WordPress?
- Stress testing WordPress
- Can I use wordpress for a non-blog site?
- Can I / Should I use WordPress as a CMS for my Flash application
- Using wordpress for a four-page website may be an overkill?
- Searching Only Blog Posts From a WordPress Site’s Main Posts Page?
- WordPress product catalog site [closed]
- What are the advantages of WordPress over other systems?
- Putting main WordPress blog under a different folder name
- Is a complex site possible with WordPress?
- Convert link in WordPress 3.2.1
- WordPress for a business catalog site
- Why are wordpress posts not hierarchical?
- Updating my wordpress CMS to 4.7 gives me a blank HTML area during the upgrade process
- Content management for static pages
- WordPress in Drupal
- Why does blog page not reveal it’s template?
- Is wordpress truly capable of anything other than blogging? [closed]
- Is wordpress a library with a default GUI?
- Editing Code for CMS *** Fixed – my own stupidity – I appologise and thank everyone for their help [closed]
- Show a different link based on IP
- Can I manage content of my custom site using wordpress?
- Get Drupal user into WordPress
- How do I add open graph tags? [closed]
- Can’t access Dashboard after WordPress 3.3 Update?
- Heterogeneous content on a page
- Multiple editable content on page
- Set a WordPress website’s language without affecting the back-end
- Can WordPress used as a CMS? [closed]
- “No X11 DISPLAY variable” – what does it mean?
- Style custom columns in admin panels (especially to adjust column cell widths)
- Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
- Any way to make posts inherit properties/taxonomies through a single assigned taxonomy
- Creating my own Admin Forms in a WordPress CMS?
- How can I use WordPress as a job board ? (but free)
- Using WordPress as piecemeal in existing site?
- Multiple level category drop-down
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- Sub-directory blog on a sub-domain WordPress network site
- Minor css-change based on topmenu – how?
- WordPress as Backend, Laravel Front End: How to connect Routes?
- Creating a searchable A-Z listing of hundreds of companies/services
- WordPress CMS – hide content from public while in editing stages
- WordPress plugin for authoring technical documentation? [closed]
- Migrating from other CMS to WP – losing SEO juice?
- Search form with Category and Sub Category
- How could I create a ‘private comments’ section on a custom post type?
- Can part of my WordPress website be headless?
- Headless WordPress – Issue with plugin path
- raw code vs wordpress
- Using the “Latest posts” feature on a different site
- Only expose routes with prefix /wp-json on WordPress using Apache
- WordPress vs. Custom PHP [closed]
- Hide comments column in WordPress backend
- We have a static Hugo website and we want to migrate it to WordPress
- How do I get the intended post type of a revision post?
- How to display only posts assigned to a particular, isolated, subcategory
- How to leave a line between paragraphs when writing text in the visual or text editor
- How to set up an entity (post-type?) with many dependent entities (more post-types?)
- Anonymous Postings
- Custom post type content using custom fields without template
- Associating two custom post types
- Should I use “Categories ” or “Pages” for a WordPress Static Site (A non blog site)?
- Advantages of wordpress theme vs wordpress as a backend only [closed]
- How to establish site-wide fields with my theme?
- Can I use WooCommerce in a headless CMS setup?
- WordPress as template engine
- Adding and removing columns from the admin pages panel
- How can I include active content in a custom post type?
- Parse a text area custom meta box and assign as value to existing meta keys
- How do I make reusable content blocks for header and footer when using WordPress headless with another front-end?
- Lost in trying to create user database system
- How do you create a re-useable HTML fragment in wordpress
- wp_nav_menu with WP as pure CMS
- What is the best way to manage small blocks of content on my home page?
- In adding CMS functionality to static website, is complete conversion the only way?
- Make separate text boxes for separate WordPress Custom Fields
- posts and cms and posts again
- How to add coupon printer?
- Get wordpress post with featured image, category and tag from WordPress API
- Where to put code that customizes API
- How to use filters/params in wordpress as headless cms api
- Migrate php folder to WordPress
- Best way to create a page outside of the pages list
- Combining fancybox with multiple thumbnail plugin
- Trying to fix multiple category drop down
- Is there a good way to use CMS images with CSS
- How can I make a custom post type that loops pages in a new dashboard page, each single page is a new dashboard page (all within the back-end)?
- CRM and newsletter integration? [closed]
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Use WordPress to create a custom CMS? [closed]
- Webhook: save_post action fires wp_remote_post twice
- How do I access the contents of WordPress Classic editor in admin area with JavaScript?
- Error Message when logging into WordPress on Xampp
- YARRP related posts with custom post type and wp-graphql
- Change links behind buttons in admin dashboard
- Customizer Changeset, Sidebar and Rest API Custom Endpoints
- Block content rendered with inline CSS. How do I reuse it in a headless setup?