Fatal error: Call to undefined function add_filter() in index.php in Wordpress
问题 I want to change my wordpress theme dynamically by user browser. So I found this code on the net and added it to my index.php file add_filter('template', 'switch_theme_by_browser'); add_filter('stylesheet', 'switch_theme_by_browser'); function switch_theme_by_browser($theme) { $browser = $_SERVER['HTTP_USER_AGENT']; if(preg_match('/MSIE/i',$browser) && !preg_match('/Opera/i',$browser)) { $theme = "twentyeleven"; } elseif(preg_match('/Firefox/i',$browser)) { $theme = "twentyten"; } elseif(preg