wordpresshttp-redirectmobiledesktop

Redirect users visiting mobile site from desktop


i created 2 different website, one for mobile and one for desktop using Wordpress! I used a plugin called equivalent mobile redirect in order to redirect mobile users to the mobile site when they visit the desktop one! Now i need to do this vice versa and i cannot seem to find a efficient way! Any ideas?


Solution

  • Take a look at this code if you don't want to use Javascript. You can use WordPress's detect mobile function to redirect if visitor is on desktop browser.

    if(!wp_is_mobile()){
        // If not using mobile
        wp_redirect( "https://your_desktop_site.com");
        exit;
    }
    

    You can add this code to your theme's functions.php file and it will work.