Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * This solution assumes you've already set up your site so that the site domain is
- * your "normal" (non-mobile) domain, and your theme is your non-mobile theme.
- *
- * In short, what it does it check to see if the site is being accessed through the
- * mobile domain. If it is, the mobile theme is used instead of the normal theme, and
- * all links point to the mobile domain (so navigatiion doesn't take visitors to the
- * regular domain.
- */
- define( 'MOBILE_DOMAIN', 'm.mysite.com' ); // Whatever your mobile domain should be
- if ( MOBILE_DOMAIN == $_SERVER['HTTP_HOST'] ) {
- // Override option table values for home_url and site_url
- // This way mobile users will stay on the mobile domain
- define( 'WP_HOME', 'http://' . MOBILE_DOMAIN . '/' );
- define( 'WP_SITEURL', 'http://' . MOBILE_DOMAIN . '/' );
- // Set up a filter to override the site stylesheet/theme for this request
- add_filter( 'pre_option_template', 'mysite_set_theme' );
- add_filter( 'pre_option_stylesheet', 'mysite_set_theme' );
- }
- // Override the regular theme with the mobile one
- function mysite_set_theme() {
- return 'mytheme_mobile';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement