Filters the REST URL prefix.
Parameters
$prefixstring- 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.
$prefixstring'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-jsonto another prefix e.g.apiadd the following code to your theme’sfunctions.phpfile 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/.