The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End “show fullversion” of mobile site

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #41881


    Could really use some brains on this one..
    I’ve used this article:
    to create a plugin which switches the theme, frontpage etc. with filters. the filters I use are these:

    //filters for changing the theme
    add_filter(‘template’, ‘stgr_filter_switchTheme’);
    add_filter(‘option_template’, ‘stgr_filter_switchTheme’);
    add_filter(‘stylesheet’, ‘stgr_filter_switchTheme’);

    //If we’ve set a different frontpage, run filter to change frontpage
    if($options != ”){
    add_filter(‘option_page_on_front’, ‘tgr_filter_switchFrontpage’);
    add_filter(‘option_show_on_front’, ‘tgr_filter_switchShowonfront’);
    //If we’ve set a different blogpage, run filter to change blogpage
    if($options != ”){
    add_filter(‘option_page_for_posts’, ‘tgr_filter_switchBlogpage’);

    But I also need a way for a mobile user to see the whole site instead if they click a link in the mobile version. What I had in mind was to have the link pass a GET variable in the URL and in the wp_config.php I check for the variable and if its set I set a session variable.

    session_start(); // start up your PHP session!
    $desktop = $_GET;
    if($desktop == ‘desktop’){
    $_SESSION = ‘desktop’; // store session data

    I then figured I could check for this session variable in the plugin and if it’s present I don’t want to run the filters.

    However it does not seem to work! I’m probably thinking about this the wrong way.. If any of you guys have a solution I would be very grateful!


    The thing is that the desktop-version is going to be completely responsive as well..However the client want a VERY different mobile-version which looks basically like a webapp which one can save to homescreen.

    I prefer not to create a different installation for it to make it as simple as possible for the client.
    It’s also working like a charm, just switching the theme and front-page and voila, I can create a completely different site from the same wp. Now I just need to be able to reverse the filters and maintain that.


    is get actually pulling version in? ie is the problem with it been stored in the session or it actually been passed too the page in the url.
    Also could we have an example of the link your using to pass the version.


    Yeah The GET is pulling version in and it is indeed setting the session variable.
    The url of the link looks like

    IF this way is possible I think my issue lies with how I handle the filters. Does anyone know wether these filters apply before browser rendering or not? I can see how it would be an issue if not since what I want is just to disable the browser rendering filters if the visitors session is stored.


    Okay just to post the “answer” for anyone interested..

    My code does work as is. There was another piece of code which interfered with my solution. So basically.. What I’ve described above works like a friggin charm if anyone needs a similar solution.

    In summary what I do is:
    * Use the script found here: to detect if a user is on a mobile
    * Run the filters to change the theme and frontpage etc. before browser rendering
    * If user clicks “show desktop version”. Pass a parameter “?version=desktop” in the url to the frontpage.
    * In wp-config.php, I check if this parameter is set, if so I set a php session variable.
    * If the session variable is set, I don’t run the previous filters

    This gives me the possibility to create a completely different mobile version which in my case is used as a webapp. It uses the same wordpress installation and database but a different theme and frontpage. Awesomesauce!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.