我正在尝试创建一个包装器快捷方式函数,以便在标题中注册和加载样式表。当前,该函数加载此css文件src:
http://my.test/wp-content/theme/css/.css
很明显,我希望它通过给定的参数。问题是,新函数定义中的新函数定义似乎没有使用参数,即使我的add\\u操作的第4个参数是1(参数可传递给函数)。我做错了什么??请帮助:)
<?php //Registering stylesheets
load_stylesheet_like_a_boss(\'my-style.css\');
function load_stylesheet_like_a_boss($filename){
echo \'parent:\'.$filename; //should return \'parent: my-style.css\'
add_action(\'wp_head\', \'stylesheet_registration\', 5, 1);
function stylesheet_registration($filename){
echo \' / child:\'.$filename.\'<br>\'; //should return \' / child: my-style.css\'
$name = str_replace(\'.css\',\'\', $filename);
wp_register_style($name, get_bloginfo(\'template_directory\').\'/css/\'.$name.\'.css\');
wp_enqueue_style($name, 10);
}
} ?>