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
- NGINX rewrite rules for WordPress Subdirectory Multisite to support deep URL
- Customize default settings on new sites on multisite
- Receiving Stripe Webhooks on a wordpress website
- Sorting list of sites from multisite network using wp_get_sites
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- Multisite wordpress and subdomain URL collisions
- Hooking new functions to actions + passing parameters
- Find variables available at a given hook
- Passing data between two hooks in separate HTML requests
- Replace existing content from specific WooCommerce admin orders list column
- Newbie question: no index.php? in my plain wordpress permalink
- enqueue hover function
- Change links automatically to affiliate links
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- using add_action for a header hook that has an additional parameter
- How to call function at the bottom of post using plugin?
- WordPress (3.9.1) MultiSite Permissions. Is chown the answer?
- Nesting if statements to echo only one string based on what tag was filtered?
- ajax, right way to do it and make it works?
- 3 blogs same installation, without WP MU
- Two Different Links for Same Product – WooCommerce [closed]
- Sending data from custom inputs in WordPress comment form in the admin notification email
- Reload part of checkout on changed shipping method
- Remove a div from RSS feed
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- Append query string to all URL’s
- WordPress returns “The link you followed has expired” error page whenever I add a new site, add a user etc
- Set meta field to publish date + 2 weeks
- WordPress Gravatar filter is removing my custom attributes
- how to combine wordpress htaccess on my root domain + php on subfolder
- Adding widgets to my plugin page instead of WordPress dashboard
- custom url rewrite for wordpress
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Modify custom field input data before creating a new post
- Are all hooks/functions tied to Kses meant for sanitization?
- Loading index.php contents which located outside blog folder for post single page
- Why does wp_head hook my functions to the beginning of my source code?
- Pass argument to event hook
- 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?
- Adding function to child theme’s function.php
- 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?
- 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;’?
- WordPress Multisite login_redirect to primary blog and specific page based on role
- How to make Subdomain work for product_tag?
- How do I add a function to parent theme
- 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
- 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
- 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
- How to use multiple 404 Error Pages in WordPress
- WordPress add parameters with friendly url structure
- Losing Session ID and sessionStorage when navigating to other domains on Multisite
- transition_post_status hook, works – but not if the post is new
- Increase Upload Size with htaccess | MAMP
- php was updated – critical error [closed]
- Facing Problem While Running WordPress Hook For Archive, Categories, Author, Date Pages Only
- Woocommerce – add tracking code to another email template
- wp-login – unable to redirect user to a custom login url
- how to append ACF field data using one of the following filter/ hooks
- Add Imports to Existing WordPress Import Map