Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能告诉我如何通过插件向主题的 head.php 添加代码?
我想在其中添加一些外部 .css 文件?
您应该在插件中使用以下代码:
add_action('wp_head', 'your_function'); function your_function(){ wp_register_style( 'external_css', 'EXTERNAL CSS PATH'); wp_enqueue_style('external_css'); }
仅供参考:可能是您提到的文件名不完整,应该是 header.php,请确定。希望这段代码对您有所帮助。一切顺利 ;)