您可以筛选site_url
使用过滤器-称为site_url
挂钩具有以下签名:
apply_filters( \'site_url\', string $url, string $path, string|null $scheme, int|null $blog_id )
您可以这样使用它:
add_filter( \'site_url\', \'wpse_381006_custom_site_url\', 10, 1 );
function wpse_381006_custom_site_url( $url ){
if( is_admin() ) // you probably don\'t want this in admin side
return $url;
// for example, return the request_uri - but this is not a complete solution, you would need to work out what you return and in what conditions..
return $_SERVER[\'REQUEST_URI\'];
}
参考号:
https://developer.wordpress.org/reference/hooks/site_url/