WordPress插件不能想head标签中自动插入css或js文件可能是由于wp_head()
函数导致的,新手站长网分享:
插件不能自动插入css或js的解决方法
WordPress有的插件需要向头部的head标签中插入css或js文件,例如:Crayon Syntax Highlighter代码高亮插件就需要向head标签中插入css和js引用,如果头部没有wp_head()
函数,就不会自动调用,它们是依赖wp_head()
函数输出的。
解决方法如下,在主题目录下的header.php文件的head标签中插入如下代码即可:
1 |
<?php wp_head(); ?> |
那么wp_head()
函数为何方神圣?以下为WordPress官方表述:
1 2 3 4 5 6 7 8 9 10 |
<?php ... /* Always have wp_head() just before the closing </head> * tag of your theme, or you will break many plugins, which * generally use this hook to add elements to <head> such * as styles, scripts, and meta tags. */ wp_head(); ?> </head> |
2022云服务器特价,便宜有好货!
① 腾讯云:腾讯云2核4G服务器8M带宽70元一年(更多配置报价查看)
② 阿里云:阿里云2核4G服务器6M带宽68元一年起(有高配)
③ 华为云:华为云1核2G服务器39元一年起(有香港节点多配置可选)
④ 代金券:腾讯云服务器代金券限量发放中...(有账号就能领)
⑤ 免费提供技术支持:在线客服