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
- Change WordPress Multisite Domain to subfolder
- 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?
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- Setting up 2 SMTP accounts: 1 for wordpress and 1 for woocommerce
- wp_loaded hook block script enquequing
- Handling Body class based on Template
- How to load a template-part based on a url wildcard?
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- Static variable and add_rewrite_rule?
- Remove an action hook within a Class
- Nesting if statements to echo only one string based on what tag was filtered?
- How to pass arguments to add_action() or retrieve return value of called function?
- hook that when page is starting to load
- Apache Fallback instead of add_rewrite_rule
- Why do WordPress rewriites seem to work differently for posts vs pages?
- Performance impact of rewriting WordPress URLs
- ajax, right way to do it and make it works?
- 3 blogs same installation, without WP MU
- Is sanitize_title_with_dashes formatting function too liberal (in terms of accepted characters)?
- Two Different Links for Same Product – WooCommerce [closed]
- Sending data from custom inputs in WordPress comment form in the admin notification email
- Edit incorrect password message WordPress
- 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
- Reload part of checkout on changed shipping method
- Trying to build simple deposit code that hooks into woocommerce
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Remove metabox from WordPress menu editor page?
- Add a product to checkout via form
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- How to change redirection route to a php page for making it only accessible by logged-in members?
- WordPress returning 404 for multisite pages
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- Why ajax doesn’t work on certain wordpress hooks?
- URL redirect/rewrite rule wordpress multisite
- Remove a div from RSS feed
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How to call plugin function per site in a multisite?
- Append query string to all URL’s
- user_profile_update_errors hook not executing
- 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
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- Error in custom php function doesn’t exist
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- how to combine wordpress htaccess on my root domain + php on subfolder
- custom rewrite rule help! Custom rewrite rules not applying to custom post type
- Don’t insert if permalink is the same?
- Return a numerical function value in Customizer controls
- Adding widgets to my plugin page instead of WordPress dashboard
- custom url rewrite for wordpress
- Use URL Rewrite as well as $_GET parameters in URL?
- How to modify URL (add GET values) after front end form submission?
- parts of url disappear when using # inside href=”” [closed]
- edit_comment_link is not showing for comment author
- NGINX rewrite rules for multisite
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Adding function to Genesis genesis_header [closed]
- Modify custom field input data before creating a new post
- how to make custom ajax handler?
- Are all hooks/functions tied to Kses meant for sanitization?
- Loading index.php contents which located outside blog folder for post single page
- Create custom permalinks to show Custom Post Type’s relationship?
- Add .htm extention to a custom taxonomy
- Help with .htaccess and Login with Subfolders
- Redirect to another page using contact form 7? [closed]
- Why does wp_head hook my functions to the beginning of my source code?
- Pass argument to event hook
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- Should `wp_login` be used since it’s deprecated?
- Moving code from theme header to functions.php
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Password minimum length in personal subscription [closed]
- How to use a custom hook
- Run a code only on theme activation only during first activation
- Is it best to avoid using $wpdb for security issues?
- Theme activation hook in php class
- Count posts on multisite with blog id
- wp_redirect only works on main site and not on other sites
- How to avoid duplicates when creating recent network posts
- Troll the hackers by redirecting them
- How do I display offsite database info on my wordpress site?
- Theme not calling Jquery properly
- Timthumb.php image gallery not working on Multisite WordPress
- How to remove the message ‘We could not find any results for your search’ without changing template files and without adding posts/pages?
- Get access to variable from previous pageview, excluding ajax-calls