I have two themes.

  1. mytheme
  2. mytheme-child

    By default my site loads with mytheme And I have a link by the header:

    <a href=" [here I have to give a code line that switches the default theme to child theme] ">Visit our mobile site</a>

    When the user click the above link Visit our mobile site the theme should be switched to the child theme.

    I spent a day of googling but could NOT find any tutorials or info for achieving this without using a plugin. How can I do this without a plugin?

  • What you want to do is a bad idea. You have three options here, create a separate mobile install and redirect to it if the user chooses to visit the mobile site, or have two different stylesheets which you load conditionally, or use responsive design. Commented Jun 3, 2015 at 6:05

1 Answer 1


I have different Point of View on that, and my solution is plugin-centric:

A mobile theme is for the user's ease-by-default, and should not for a user's ease-by-choice. Take the scenario:

  • a mobile theme is highly optimized
  • a mobile theme is designed with less resources (it serves lesser dev. resources to the user)
  • a mobile theme is lesser width devices-friendly

So, if a user browse my site with high load (the desktop theme), what's the purpose of a mobile-friendly theme then?

So, in my opinion, a mobile theme should be offered at the very first stage, and if it's automated, it'd be nicer. And then let the user choose whether they want to load the desktop site (parent theme) or stay into the mobile site (child theme).

I relied on Any Mobile Theme Switcher plugin by Dinesh Karki. It's an awesome free plugin that,

  • offers different theme for different devices
  • shortcode functionality for theme switching

any mobile theme switcher different theme for different devices

My POV: While a plugin solves everything why not I use it solely? If I have obligation using a complete plugin for my purpose, then grab the code from the plugin and grab the necessary bit from there, or write down my own grabbing idea from there.

Without plugin

I still don't have any without-plugin-solution to this issue. But if you really in need of such functionality then I can assume you can code yourself using the technology:

  1. How the Theme Test Drive plugin activates a theme on choice
  2. Use two switching buttons and activate different theme using the method of #1

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.