Support » Fixing WordPress » How to redirect to another page using a function?

  • I have a simple task to accomplish.

    I need a function that detects if the user is on the homepage and is coming from a mobile device to redirect him to page_id=2 instead.

    So far I have this, but no idea how to actually do the redirect in wordpress.

    function mobile_redirect()
    {
        if( is_home() && wp_is_mobile() )
        {
            // redirect to page_id=2
        }
    }
    add_action( 'template_redirect', 'mobile_redirect' );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to redirect to another page using a function?’ is closed to new replies.