Skip to content

Instantly share code, notes, and snippets.

@shivapoudel
Created January 12, 2018 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shivapoudel/b822b4b95e7aa2fe1cc0d75da4b26563 to your computer and use it in GitHub Desktop.
Save shivapoudel/b822b4b95e7aa2fe1cc0d75da4b26563 to your computer and use it in GitHub Desktop.
WP REST API - Modify API base URL prefix.
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'rest_url_prefix', 'custom_rest_url_prefix' );
/**
* Modify url base from 'wp-json' to 'api' prefix.
*/
function custom_rest_url_prefix() {
return 'api';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment