• I’m not familiar with child themes but want to know if there’s a way to redirect users to a child theme based on their viewing habits, like a mobile or tablet device?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Not that I’m aware of but have you tried looking for a responsive theme?

    Thread Starter openbayou

    (@openbayou)

    I would prefer child themes for mobile and tablet devices but the theme I’m using now has 35K CSS file and the template files are around 25K to 40K. Plus there are blocks that are designed for desktop mode and I would have to create a special block for mobile and use CSS to hide one block, etc.

    A responsive theme is not out for me, just as a last resort.

    Thread Starter openbayou

    (@openbayou)

    So far, I found a way to switch to child themes on mobile devices:

    # Parent Theme
    add_filter( 'template', 'my_mobile_template', 99999, 1);
    function my_mobile_template($template){
        if(wp_is_mobile())
            return 'mobile_template_dir_name';
        return $template;
    }
    
    # Parent or Child Theme (if applicable)
    add_filter( 'stylesheet', 'my_mobile_stylesheet', 999999, 1);
    function my_mobile_stylesheet($stylesheet){
        if(wp_is_mobile())
            return 'mobile_stylesheet_dir_name';
        return $stylesheet;
    }

    So far, it pulls the CSS from the child theme. Is there a way to use the header.php in the child theme instead of the primary?

    Have a look at some of the theme switcher plugins. Maybe there’s code in there that you can re-use.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Redirect to child theme based on broswer, particularly mobile?’ is closed to new replies.