• I have a WordPress Multisite installation (subdomain) with 100+ websites, and I would like to redirect all mobile users to a mobile theme (Mobius theme, for example https://www.mobilizetoday.com/freebies/mobius/).

    I know there is several ways to do it (pgp, a plugin), but I am wondering which one would be the best way to go.

    Thank you.

Viewing 1 replies (of 1 total)
  • Phil

    (@owendevelopment)

    There’s lots of ways to do this, some better/easier than others.

    For a quick fix, you can use code in the header.php like this:

    <script>
    //<![CDATA[
        //var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
    	var mobile = (/iphone|ipad|ipod|android|sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera mini|nitro|j2me|midp-|cldc-|netfront|mot|up.browser|up.link|audiovox|blackberry|ericsson|panasonic|philips|sanyo|sharp|sie-|portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc|smartphone|rover|ipaq|au-mic|alcatel|ericy|vodafone|wap1|wap2|teleca|playstation|lge|lg-|htc|dream|webos|bolt|nintendo|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
        var refUrl = document.referrer; // Get the URL where the user came from
        var prevUrl = refUrl.substr(7,41); // Create a substring after 'https://' and '.com'
            var mobileUrl = "mobilesiteurl.com"; 
    
            //document.location = "https://m.azharkamar.com";
    		if ((mobile) && !(prevUrl == mobileUrl)) {
    		document.location = "https://mobilesiteurl.com";
        }
     //]]>
    </script>

    You can grab code for this in any langauge here.

Viewing 1 replies (of 1 total)
  • The topic ‘Best way to redirect mobile users to mobile theme (100 sites, WP Multisite)’ is closed to new replies.