Remove the REST API and oEmbed links
Removes the REST API and oEmbed discovery links from the page head and the HTTP headers. The REST API itself keeps working.
<?php
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'template_redirect', 'rest_output_link_header', 11 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
Good to know
Other WordPress sites use the oEmbed links to show a preview card when someone pastes a link to your posts. Leave this off if you want those previews.
In these packs
- Clean up the head: Remove the links, scripts and styles WordPress adds to every page that most sites never use.