-
-
Save jordanmaslyn/7e28423ef43cdb6af068f5f192077746 to your computer and use it in GitHub Desktop.
<?php | |
/* | |
* Replacing domain for rest api requests from Gutenberg editor if youre using | |
* WP headless and WP_SITEURL & WP_HOME are not the same domain | |
* (has nothing to do with yoast) | |
*/ | |
add_filter('rest_url', function($url) { | |
$url = str_replace(home_url(), site_url(), $url); | |
return $url; | |
}); | |
/* | |
* Replacing domain for stylesheet to xml if youre using WP headless | |
* and WP_SITEURL & WP_HOME are not the same domain | |
*/ | |
function filter_wpseo_stylesheet_url( $stylesheet ) { | |
$home = parse_url(home_url()); | |
$site = parse_url(site_url()); | |
return str_replace($home, $site, $stylesheet); | |
}; | |
add_filter( 'wpseo_stylesheet_url', 'filter_wpseo_stylesheet_url', 10, 1 ); |
Hi, I'm facing one issue.
when i changed the Site address URL to the frontend url, My WordPress application stopped working properly, like i can't login or if i login then i can't log out, The issue i noticed. WordPress Login form action is set to the WordPress application URL. In this case what i can do.
@sbnoman01 Hmmm, I have not seen that behavior before. It sounds like you may have changed the wrong URL setting. If doing it from the WP Admin dashboard, make sure you are changing the setting titled "Site Address (URL)" or if you are changing it in code/the database, make sure you are changing home_url
(not site_url
). With that change and the rest_url
filter above, you should be A-OK logging in and out of the WordPress dashboard like normal.
In the admin, "WordPress Address (URL)" and in code/database site_url
should always reflect the URL to your WordPress installation.
Hi @jordanmaslyn Thank you for your response, Basically, i changed "Site Address (URL)" from wp-admin/options-general.php then everything looks good but when I try to log in from any other browser or try to logout from right top corner it redirects me to the Frontend url with the required parameters.
Note: if you use migrateDB pro, changing
home_url
will break the default rewrites and then your .local will be redirected to .com backend. To fix, just add a custom rewrite rule.