You can change the options siteurl
and home
.
add_action('after_setup_theme', 'maybe_mobile_url');
function maybe_mobile_url() {
if ( wp_is_mobile() ) {
add_filter('option_siteurl', 'add_mobile_url' );
add_filter('option_home', 'add_mobile_url' );
}
}
function add_mobile_url ($url) { return $url . '/mobile'; }
But, I think, that if you define WP_SITEURL
and/or WP_HOME
in config.php
it will fail, and you will have to add filter to all the function that retrieve permalinks.