Filters the REST URL prefix.
Parameters
$prefix
string- URL prefix. Default
'wp-json'
.
Source
return apply_filters( 'rest_url_prefix', 'wp-json' );
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |
Filters the REST URL prefix.
$prefix
string'wp-json'
.return apply_filters( 'rest_url_prefix', 'wp-json' );
Version | Description |
---|---|
4.4.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
Flushing rewrite rules is required for new prefix to work. Simplest method is to visit Settings/Permalinks in your admin panel & Save Changes with existing settings. It will refresh your permalinks.
If you want to change WordPress’s default REST API URL prefix from
wp-json
to another prefix e.g.api
add the following code to your theme’sfunctions.php
file or in a custom plugin:Now, refresh rewrite rules by going to Settings -> Permalinks and hit Save Changes.
Your new REST API URL will be
example.com/api/
instead of the defaultexample.com/wp-json/
.