Skip to content

Instantly share code, notes, and snippets.

@mishterk
Created October 14, 2021 02:00
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 mishterk/13f6dedc3b68ffdaf19677d4185d882e to your computer and use it in GitHub Desktop.
Save mishterk/13f6dedc3b68ffdaf19677d4185d882e to your computer and use it in GitHub Desktop.
How to customise the WordPress REST API URL prefix (wp-json). This snippet is for the https://hookturn.io/2021/10/how-to-customise-the-wordpress-rest-api-url-prefix-wp-json/ blog post.
<?php
// This will replace the 'wp-json' REST API prefix with 'api'.
// Be sure to flush your rewrite rules for this change to work.
add_filter( 'rest_url_prefix', function () {
return 'api';
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment