• Resolved birken

    (@birken)


    Hello,

    i wish to show word press site only for mobile devices, is that possible?
    hide for all desktop.

    regards B

    • This topic was modified 3 years, 9 months ago by birken.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jose

    (@giuse)

    Hi @birken

    the actual version of this plugin can’t help you to do this, it gives you only the possibility to display different content for mobile devices.

    If you want, you can write a couple of lines of code in your functions.php to do what you need:

    function my_redirect_on_desktop() {
        if ( !wp_is_mobile() ){
            wp_redirect( 'https://another-website-example.com' );
            die();
    	exit;
        }
    }
    add_action( 'template_redirect','my_redirect_on_desktop' );

    The code above will redirect the desktop user to https://another-website-example.com. Replace it with the URL where you want the redirection.

    The same code without the line wp_redirect…. will show a blank page on desktop.
    So if instead of the redirection you want to show a blank page, add only the following code in your functions.php:

    function my_redirect_on_desktop() {
        if ( !wp_is_mobile() ){
            die();
    	exit;
        }
    }
    add_action( 'template_redirect','my_redirect_on_desktop' );

    If you have a plugin for server cache, remember to distinguish between the mobile and desktop cache, in another case you will have problems caused by the cache.

    • This reply was modified 3 years, 9 months ago by Jose.
    • This reply was modified 3 years, 9 months ago by Jose.
    Thread Starter birken

    (@birken)

    oh i see,

    i using your plugin just now created a mobile version and removed everything in desktop version so is a blank page. and it seem to work or am i doing something not right?

    what i mean you are mention cache things will i have some problems with the way have done it with your plugin?

    as i am not coder so i am little novice with this.

    warm regards B

    Plugin Author Jose

    (@giuse)

    @birken if you were able to reproduce a blank page without code, what you have done is perfect. I’ve posted that code because usually the theme doesn’t give you the possibility to show a page without header and footer, but I suppose in your case you can do it, so you don’t need any code.

    The server cache is a problem when, the server sends something different to mobile and desktop devices, as in this case. No matter if you do it with this plugin or in another way.

    As you probably know, when a page is served by server cache, that page is not dynamically generated every time the user request it, but a static already generated page is sent to the user browser. The cached page is generated when the user visits for the first time that page, then other users will see the cached version.

    So, imagine the following scenario. In the beginning, you have no cache. A first user visits your page with a desktop device, so a blank page is saved in the server cache.
    Next user visits the same page with a mobile. On mobile, you don’t want to show a blank page, but because the cached version was generated visiting the page with a desktop, also the second user will see a blank page, also on mobile.

    If you want server cache, better you use a plugin that gives you the possibility to distinguish between desktop and mobile, as e.g. W3 Total Cache, or WP Fastest Cache. You have also other plugins that can do it.
    You can set up this kind of plugins in a way that the mobile cache is generated only when the user visits the page with a mobile, and the desktop cache is generated only when they visit the page with a desktop. In this case, the cache will not give problems.

    Thread Starter birken

    (@birken)

    fantastic thx,

    yes i forgot to say that i don use any header or footer just a short code in page body so the page is perfect blank on desktop. i dont use any cache plugins but seem to work for me i have tried on different mobile devices no blank page yet.

    so your plugin is perfect for me 🙂

    Plugin Author Jose

    (@giuse)

    perfect!
    So, I will close the thread if you have any issues, don’t hesitate to open a new one.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘hide site?’ is closed to new replies.