WordPress.org

Ready to get started?Download WordPress

Forums

PHP Browser Detection
[resolved] Single page mobile redirect (5 posts)

  1. John
    Member
    Posted 10 months ago #

    Hello, I have been attempting to redirect just one of my WordPress pages for mobile users with the use of this plugin, however I have gotten stuck. This is the code I'm using so far:

    <?php
    if ( is_mobile() && get_the_ID(2766) ) {
    wp_redirect('http://www.lifebyjohn.com/mobile-schedule');
    exit;}
    ?>

    I tried adding the code in header.php, as well as using the Code Snippets plugin so that it would go in functions.php. Did I mess the code up by chance? Or am I putting the code in the wrong place? I'm a relative newbie so patience with me would be appreciated :-)

    Thanks!

    http://wordpress.org/plugins/php-browser-detection/

  2. Mindshare Studios, Inc.
    Member
    Plugin Author

    Posted 10 months ago #

    That code looks like it should work, can you send a URL to your site I can check?

  3. adidouh113
    Member
    Posted 7 months ago #

    ...get_the_ID() == 2766

  4. Mindshare Studios, Inc.
    Member
    Plugin Author

    Posted 7 months ago #

    Yes adidouh113 is correct! You should use:

    if(is_mobile() && get_the_ID() == 2766) {
    //
    }
  5. erjdavis
    Member
    Posted 3 months ago #

    Here is a wordpress plugin that allows you to do what you're looking for - http://ultimate-wordpress-mobile-redirect.com/

    You can set the single page you want redirected and you can choose different redirects for every page/post.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.