WP REST API Is it rather easy to rename the default wp-json uri part?

Please note that for current versions of WordPress, using the json_url_prefix filter no longer works.

On WordPress 4.7 (and using the REST API from the core instead of a plugin), this is what I needed to change the API prefix.

add_filter( 'rest_url_prefix', 'my_theme_api_slug'); 
function my_theme_api_slug( $slug ) { return 'api'; }

If this doesn’t work straight away, you’ll need to flush the rewrite rules. You can run this piece of code once to do so (don’t leave it in your code so it runs everytime):

flush_rewrite_rules(true);

Leave a Comment