Last active
December 28, 2020 14:10
-
-
Save wpscholar/d60ab5ba42a4323bdde06228124a4f62 to your computer and use it in GitHub Desktop.
A WordPress plugin that updates the REST URL to use the site URL instead of the home URL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom Rest URL | |
* | |
* @package CustomRestUrl | |
* @author Micah Wood | |
* @copyright Copyright 2021 by Micah Wood - All rights reserved. | |
* @license GPL2.0-or-later | |
* | |
* @wordpress-plugin | |
* Plugin Name: Custom Rest URL | |
* Plugin URI: https://gist.github.com/wpscholar/d60ab5ba42a4323bdde06228124a4f62 | |
* Description: A WordPress plugin that updates the REST URL to use the site URL instead of the home URL. | |
* Version: 1.0 | |
* Requires PHP: 5.6 | |
* Requires at least: 5.0 | |
* Author: Micah Wood | |
* Author URI: https://wpscholar.com | |
* License: GPL V2 or later | |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html | |
*/ | |
add_filter( | |
'rest_url', | |
function ( $url, $path, $blog_id, $scheme ) { | |
return get_site_url( $blog_id, trailingslashit( rest_get_url_prefix() ) . $path, $scheme ); | |
}, | |
10, | |
4 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment