Ok. Then you can use template_redirect hook and wp_is_mobile() conditional tag. wp_is_mobile() will work on device only. If you resize the window then it will not work. Now you can try this kind of code in your functions.php file
add_action('template_redirect', 'redirecting_to_mobile_site');
function redirecting_to_mobile_site(){
if( wp_is_mobile() ){
wp_redirect( 'http://m.example.com', 301 ); exit;
}
}
Related Posts:
- Fix 403 error on WordPress multisite network using subdomains
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- subdirectory index.php is not working
- WP & Server Speed [Teacher Question]
- WordPress add_rewrite_rules for custom URLs ending in .html
- How to disable all logins except Network login in WordPress Multi site?
- Internal Server Errors – Moving working multi-site install to my localhost
- Resource 404 error on multisite subdirectory install
- Using register_activation_hook in classes
- WordPress and event-driven programming – what is it about?
- How can I modify the permalink via a filter?
- How does wordpress know which site to setup (on multisite)?
- How to remove a metabox from menu editor page?
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- Bypass .htaccess when using download_url
- Network installation giving errors when viewing or adding a user
- How to Remove a Filter from the Admin List Table?
- How to redirect all 404 in a WordPress subdirectory to the index.php of subdirectory?
- Woocommerce, recognize the loop of related products
- How to create Sub Sub domain Multi User blogs?
- Why am I getting ERR_NAME_NOT_RESOLVED when I add a site to my multisite installation? [closed]
- How To Change The Html of Products filtration sidebar in Woocommerce?
- Insert all post IDs in new database table
- Change the actual (or viewable) WordPress directory structure
- Custom php page outside the scope of my theme
- How to add a second ‘place order’ button in WooCommerce [closed]
- Cannot get media type from ‘x-mapp-php5’
- Adding hreflang tags automatically in WordPress subdirectory multisite
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- wp_loaded hook block script enquequing
- Static variable and add_rewrite_rule?
- hook that when page is starting to load
- Apache Fallback instead of add_rewrite_rule
- wordpress media library new uploads don’t write to database
- Was told to change the .htacess file form .html to .php so this would work properly
- Remove metabox from WordPress menu editor page?
- Why ajax doesn’t work on certain wordpress hooks?
- How to call plugin function per site in a multisite?
- How to add an arrow to menu items has submenus
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Don’t insert if permalink is the same?
- parts of url disappear when using # inside href=”” [closed]
- NGINX rewrite rules for multisite
- Create custom permalinks to show Custom Post Type’s relationship?
- Why does wp_head hook my functions to the beginning of my source code?
- Pass argument to event hook
- Timthumb.php image gallery not working on Multisite WordPress
- How to catch wordpress post ID when it’s published
- Why does the post_type_link hook everything twice?
- How can I hook into the wp_mail function used by BackWPup?
- How to allow download url redirection only if user logged in WordPress site?
- How to add a rewrite endpoint to unattached media?
- Removing files programmatically
- Custom post type url Rewrite (conflicting with page url)
- Why doesn’t global $wp_query not get hooked?
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- Authentication from sub-folder non-wp cookie WordPress
- How to pass hook variable to function?
- WordPress Rewrite Rule
- Why is home page content not displaying with this rewrite rule?
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- How to serve WordPress folder over subdomain?
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Use wp_head hook on template page
- Adding custom field to product category and show it to shop/category shop page
- How to edit post meta data before publishing the post it self wordpress?
- Rewrite rule not working, but only when parameter is text
- Get original value in save_post action hooka
- get Woocommerce product format json for WP_Query
- How To Use htaccess to Rewrite Link Structure for a Page that is Generated Programatcially
- Is there an option to execute javascript file only on plugin activation
- How do I remove an action hook inside a class that is called by another class?
- Merging Multiple WordPress Websites
- Help hooking into user_register
- Multiple WordPress sites with different theme and plugin sharing the same content
- Hook into all password resets in WordPress and get password before hashing?
- PHP script to redirect traffic based on website accessed
- Why transition_post_type hook is called twice for the same post?
- Problem with ajax request and directory structure after site migration
- Transfer WordPress Login Session to an Extended Webpage on the Same Domain
- redirect 301 with special character like WIX site “#!”
- Post formating on Home page
- WP Admin Bar – Get current theme name as custom menu title
- Redirect homepage /page/1/ to /blog/page/1/
- WordPress HTML Helper
- How to print redirected query string variables to the page?
- calling a function from a class in your template
- Multiple URL from Custom post name
- Enabling XSendFile causes 404 for images on WordPress Multisite / Network
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- Trying to post information from a remote database to wordpress page
- Change Checkout “Place Order” text if cart has a specific product
- Losing Session ID and sessionStorage when navigating to other domains on Multisite
- Custom taxonomy with page post type – WordPress
- understanding wp_next_scheduled
- Add/alter image attribute before render
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Internal server error when enabling Multisite in WordPress
- Is there a hook that I can use when a fatal error occurs?