由于我升级了IMAC的系统,导致电脑上的XAMPP不能运行,所以在制作主题的过程中需要在线测试,但是新主题还是个框架,还不能让访客查看,博客虽然没几个人看,保持良好的界面形象是你对他人的一种尊重。 于是想到对于Wordpress的管理员显示测试主题,对于访客显示正常主题。使用如下代码实现:
add_filter('template', 'admin_theme'); add_filter('option_template', 'admin_theme'); add_filter('option_stylesheet', 'admin_theme'); function admin_theme($theme) { if(current_user_can('level_10')){ $theme = 'Font'; } return $theme; }