Hi all,
I have 2 different themes for my website: one is for desktop, and one is for mobile. Now I want to switch them automatically based on users device. I’ve found [ Change theme dynamically](Change theme dynamically) but there is some code missing because there is no text after the final doublepoint
Maybe anyone could share the full code how to switch themes based on users device?
Maybe there was just no code behind the : in the mentioned post ?
Anyway, I think it should be possible with the given hint.
Just try an event Hook like this which is fired just before the theme is rendered, as said.
refer to the Plugin Tutorial on how to act upon event occurrence.
at that point, you should evaluate which theme is currently in use and switch, if it is not the one you wish in case of mobile_detect == true.
Thanks @hoernerfranz for the info! Instead of this deep dive, I’ll create a separate subdomain m.mydomain.com and copy all the files to that place with a different theme by default. Nevertheless thanks for your support!
@pamtbaau, sure, most templates are responsive. But you still have the same stuff, just displayed more nicely. With dedicated themes for mobile (and or tablet) and desktop you could also decide better about the size of the page. In many cases mobile has a slower network than desktops. Therefore e.g. in my blog overview I could display 10 latest entries on desktop but just 5 on mobiles.
Additionally I see that many sites have additional subdomains m.mydomain.com , probably due to the mobile-first trend.
My theme looks completely different on mobile and on desktop. On mobile it’s more like an app, with tab bar at the bottom. That does not make too much sense on desktops.