Show switch to mobile link on desktop version only to users who come from mobile site

I used wordpress for a site and any theme switcher, wich gives me a link to switch betwen different themes of the web, Also used a code to redirect to a “mobile friendly” home page created specific for mobile users.

If a mobile user clicks on switch to desktop version a link to switch back to mobile version should apper. I used wp_get_referer(); and according to this code. should work but nothing happens. 🙁

Read More
add_action( 'storefront_footer', 'boton_movil', 20 );       


function boton_movil(){     

    $referer = wp_get_referer();
    $sitio = get_site_url();
    $mobil = $sitio.'/mobile';
if ($referer == $mobil ) {


?>
 <div class="footer_mobil">
<a href="<?php get_site_url(); ?>/mobile/?am_force_theme_layout=mobile"><i class="fa fa-desktop"></i></a>
<div class="texto_menu_mobil">
            Go back to mobile version
            </div>
        </div>

<?php

}



    }

Of course if a users comes directly to a desktop version, the link should not appear

Related posts

1 comment

Comments are closed.