How to redirect websites in mobile with in wordpress

  • September 5, 2019
  • Wordpress

Hello readers,
Here i have come with some solution for the wordpress site, how you redirect your website to

If you want to redirect your site in mobile with then you have to add following code in your theme functions.php file

function redirect_mobile(){
   if ( wp_is_mobile() ) {
    wp_redirect( 'http://url' ); 

add_action('wp_head', 'redirect_mobile'); // Action that check agent from broser.

In this wp_is_mobile() this will checks if the user is visiting using a mobile device. This is a boolean function, meaning it returns either TRUE or FALSE. It works through the detection of the browser user agent string ($_SERVER['HTTP_USER_AGENT'])

Leave a Reply