WordPress不使用插件通过程序php代码临时修改Theme主题 图文教程

最近在在帮小伙伴定制手机版公众号的内容,需要在手机版下另外定制一套主题,这里我们大致给一下思路。仅供参考

function use_mobile_theme( $current_theme ) {
    if ( is_mobile() ) {
        return 'uziwp_mobile';
    } else {
        // Otherwise, keep the current theme
        return $current_theme;
    }
}

add_filter( 'stylesheet', 'use_mobile_theme' );
add_filter( 'template', 'use_mobile_theme' );

如果uziwp_mobile是子主题,则不需要template钩子。


已发布

分类

作者: