WordPress at a glance
function is not described

rest_api_register_rewrites() WP 4.4.0

Adds REST rewrite rules.

No Hooks.

Return

null. Nothing.

Usage

rest_api_register_rewrites();

Notes

  • See: add_rewrite_rule()
  • Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.

Changelog

Since 4.4.0 Introduced.

Code of rest_api_register_rewrites() WP 5.7.2

<?php
function rest_api_register_rewrites() {
	global $wp_rewrite;

	add_rewrite_rule( '^' . rest_get_url_prefix() . '/?$', 'index.php?rest_route=/', 'top' );
	add_rewrite_rule( '^' . rest_get_url_prefix() . '/(.*)?', 'index.php?rest_route=/$matches[1]', 'top' );
	add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/?$', 'index.php?rest_route=/', 'top' );
	add_rewrite_rule( '^' . $wp_rewrite->index . '/' . rest_get_url_prefix() . '/(.*)?', 'index.php?rest_route=/$matches[1]', 'top' );
}