• I have an existing page created in WordPress. This page has its own PHP page template file. When someone visits this page from a mobile device, I want the correct page to be served to the visitor. I am doing this now using the header method in PHP. Since WordPress has already loaded, is there some PHP method to simply load the desired WordPress page without using the header method?

    <?php
    if(wp_is_mobile()) {
      header("Location: http://yn7.c6f.myftpupload.com/mobile-splash/");
      exit();
    }
    else {
      header("Location: http://yn7.c6f.myftpupload.com/desktop-home/");
      exit();
    }
Viewing 1 replies (of 1 total)
  • header is not a good use here, why not you use one template file but with your condition you load the template-content relevant to the condition?
    for example

    <?php
    if(wp_is_mobile()) {
      include the mobile template content
    }
    else {
    include the desktop template
    }

    please note that any parameters passed to this request still passed to the other templates you will include so you still have access to any variables you needed

Viewing 1 replies (of 1 total)

The topic ‘Loading a WordPress Page from a WordPress PHP Page Template File’ is closed to new replies.