• dfwgreg

    (@dfwgreg)


    I’m making a mobile theme for my site and need to know how to put the code to switch to desktop mode in my theme.

    Thanks,
    Greg

Viewing 6 replies - 1 through 6 (of 6 total)
  • FaceLord

    (@facelord)

    I’ve been trying to figure out the same thing.

    There is an option under Appearance > Mobile Switcher that will add links to your footer on the mobile theme as well as the desktop theme.

    The problem with this method for me is; The links it adds aren’t where I want them, and they don’t seem to have a class or ID for CSS styling. It’s just a p tag with an anchor link in it.

    I can replicate the code from these links and place my own button where I want.
    <a href='?wpmp_switcher=mobile' onclick='document.cookie="wpmp_switcher=desktop;path=/;expires=Tue, 01-01-2030 00:00:00 GMT";'>
    But… as soon as I uncheck the box in the settings page, the links no longer work.

    I’d really like to be able to add my own links.

    FaceLord

    (@facelord)

    Turns out my code was slightly wrong. I had a single quote inside a single quote.

    This code actually works:

    <a href='?wpmp_switcher=desktop' onclick='document.cookie="wpmp_switcher=desktop;path=/;expires=Tue, 01-01-2030 00:00:00 GMT";'>Switch to our desktop site</a>

    Thread Starter dfwgreg

    (@dfwgreg)

    Got it working! Thanks!

    Now another question: Is there a way to hide the “Switch to mobile site” on my main theme that can only be displayed when on a mobile phone?

    I was looking exactly for the same thing.
    I think the answer it’s on line 212 on this file:

    \plugins\wordpress-mobile-pack\plugins\wpmp_switcher\wpmp_switcher.php

    case WPMP_SWITCHER_DESKTOP_PAGE:
    print "<p>" . wpmp_switcher_link('mobile', __('Switch to our mobile site', 'wpmp')) . "</p>";
    break;

    You can change what it prints or print a different tag (like a div) as well as adding a custom class, or just comment it from 211 to 213. It worked for me.

    Cheers

    BTW, in order to apply a custom class to the tag, remember to change the double quotation marks for inverted commas (dunno how to say this in english).

    Example:

    The code is written like this:

    print "<p>" . wpmp_switcher_link('desktop', __('Switch to our desktop site', 'wpmp')) . "</p>";

    So, change it to:

    print '<p class="your-classname">' . wpmp_switcher_link('desktop', __('Switch to our desktop site', 'wpmp')) . '</p>';

    Otherwise, it won’t work ??

    Great info guys! I have a question to add. What if I want to put the code onto a site that is NOT wordpress. How do I do that?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘[Plugin: WordPress Mobile Pack] Need code to switch to desktop mode in my theme’ is closed to new replies.