rest_api_register_rewrites()
Adds REST rewrite rules.
No Hooks.
Return
null
. Nothing (null).
Usage
rest_api_register_rewrites();
Notes
- See: add_rewrite_rule()
- Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.
Changelog
Since 4.4.0 | Introduced. |
rest_api_register_rewrites() rest api register rewrites code WP 6.6.2
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' ); }