• I build a custom theme to make homepage with different view depends on device.
    This is th code I switch the template for frontpage:

    add_filter( 'template_include', 'front_page_template', 99 );
    
    function front_page_template( $template ) {
    
        if ( wp_is_mobile() && is_front_page() ) {
            $new_template = locate_template( array( 'page-home-mobile.php' ) );
            if ( '' != $new_template ) {
                return $new_template ;
            }
        }
    
        return $template;
    }

    It only works for desktop and mobile device.
    Are there any other way to make a tablet cache?

    I try to use filter to determine tablet device with “Mobile Detect” library.
    Like:

    add_filter( 'wp_is_mobile', 'custom_is_mobile', 101 );
    
    function custom_is_mobile($is_mobile) {
        global $mobile_detect;
    
        if(!$mobile_detect->isMobile() && $mobile_detect->isTablet()){
            $is_mobile = false;
        }
    
        return $is_mobile ;
    }
    

    It seems like not work.
    Do you hv any other suggestion for these? Thank you

Viewing 1 replies (of 1 total)
  • The plugin has mobile theme support on the advanced settings page but it’s very old and obsolete. It depends on a list of mobile browsers rather than using the WP mobile detection but you can modify that list by using the filters “cached_mobile_browsers” and “cached_mobile_prefixes” or “cached_mobile_groups” – look in wp-cache.php for those filters to see some brief comments.

    Revamping the mobile detection is on my todo list but unlikely to change for some time.

Viewing 1 replies (of 1 total)
  • The topic ‘Is it possible to have desktop/ mobile and tablet cache separately’ is closed to new replies.