Mobily – Mobile Theme Switcher
Show a separate theme on iPhone, iPad, Android and other mobile devices – with a visitor switch link, shortcode and block.
Install in
Mobily serves a different theme to mobile visitors while desktop visitors keep your active theme. Pick a theme for each device class – or leave it at “Same as desktop”.
Features
- Theme per device: iPhone & iPod touch, iPad, Android phones, Android tablets and all other mobile devices (Kindle, Opera Mini, BlackBerry, …).
- Classic and block themes are supported. Every theme keeps its own menus, widgets, Customizer settings and global styles.
- Visitor switch: visitors can change between the mobile and the desktop version. Their choice is remembered in a cookie (lifetime configurable).
- Block “Theme Switch Link” for posts, pages and block theme templates, plus the classic shortcode
[wp_mobily_shorter]. - Preview each device theme as an administrator without affecting visitors.
- Cache-safe: optional
Vary: User-Agent, Cookieheader; pages shown because of a visitor choice are never cached. - Safe by design: the admin area, REST API, AJAX, cron, the login page and the Customizer always use the desktop theme.
- Abilities API: read-only ability
wp-mobily/get-theme-for-user-agenttells AI assistants, MCP clients and scripts which theme a user agent gets (requires theswitch_themescapability). - Modern code base for PHP 8.3+ – lightweight, no external requests, no tracking, no ads.
Switch links
?mobily_wp_theme_layout=mobile– show the mobile theme?mobily_wp_theme_layout=desktop– show the desktop theme?mobily_wp_theme_layout=auto– forget the choice and detect the device again
The values mobily and orginal of older versions still work.
For developers
- Filter
mobily_detected_device– change the detected device (iphone,ipad,android,android_tablet,mobileor empty for desktop). - Filter
mobily_target_theme– change the stylesheet served to the current visitor. -
Ability
wp-mobily/get-theme-for-user-agent– inputuser_agent(and optionallayout:auto,mobile,desktop), outputdevice,device_label,theme_slug,theme_name,is_mobile_theme:wp_get_ability( ‘wp-mobily/get-theme-for-user-agent’ )->execute( array( ‘user_agent’ => $ua ) );
Privacy
Mobily does not store personal data, does not contact external services and does not track visitors. If a visitor uses the switch link, a functional cookie (mobily_wp_theme_layout) remembers the choice. A suggested text for your privacy policy is added under Settings › Privacy.
Written by Joobi from the project's own listing. See the source page
5.0.0
- Renamed from WP-Mobily to Mobily – Mobile Theme Switcher (slug, shortcode, links and settings stay the same).
- Complete rewrite for WordPress 7.0+ and PHP 8.3+ (tested with PHP 8.3, 8.4, 8.5 and WordPress 7.1): strict types, enums, readonly value objects, own autoloader.
- New: Abilities API integration – read-only ability “Get theme for a user agent”.
- New: “Other mobile devices” class, Android tablets and phones handled separately.
- New: block “Theme Switch Link”, shortcode attributes
mobile_text,desktop_text,class. - New: administrator preview per device, configurable cookie lifetime, optional
Varyheader, reset link (?mobily_wp_theme_layout=auto). - New: settings page with a modern card layout.
- New: each mobile theme uses its own theme mods, menus and widgets.
- Fixed: switch links of older versions did not work reliably (
mobilevs.mobily), link texts could not be saved, PHP 8 warnings. - Fixed: the mobile theme was also loaded in the admin area, REST API and AJAX requests.
- Security: all input is validated against whitelists, all output is escaped, the cookie is
HttpOnly,SameSite=LaxandSecureon HTTPS. - Security: responses that depend on the visitor’s choice or a preview are marked as private/no-store and excluded from page caches (prevents cache poisoning).
- Removed deprecated WordPress functions (
get_themes,get_current_theme).
4.0
- Tested with WordPress 5.6.
3.1
- Tested with WordPress 4.9.4.
2.0
- Fixed a query bug, tested with WordPress 4.4.
1.0
- First release.
Follow this listing's changes (Atom feed)