在 wp_head 之后插入 head 标签
使用 WordPress 2.9.2。我正在加载插件的 css 文件,因为它们被调用,这当然是在我的标头加载之后。我想在页面的 HEAD 标记中插入调用这些 css 文件,如果我在调用 wp_head() 后得到一个包含头部行的钩子,则可以完成此操作。帮助 !
Using wordpress 2.9.2. I am loading my css files for plugins as they are being called, which ofcourse is after my header has been loaded. I want to insert the calls those css files in the HEAD tag of the page, which can be done if i get a hook which includes lines in the head after wp_head() has been called. Help !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看 http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head -该操作称为 wp_head。
您需要使用 wp_register_style() 来注册 CSS 文件,然后使用 wp_enqueue_style() 将其实际添加到输出的样式表列表中。
该页面上有一个示例,但将示例中的“wp_print_styles”替换为“wp_head”。
Look at http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head - the action is called wp_head.
You will want to use wp_register_style() to register your CSS file followed by wp_enqueue_style() to actually add it to the list of stylesheets that are output.
There is an example on that page, but replace 'wp_print_styles' in the example with 'wp_head'.
您是否尝试过在传递到 wp_print_styles 的函数中回显样式或 .css API 操作挂钩 ?
Have you tried echoing the styles or .css include the in a function passed into wp_print_styles API action hook?
如果您使用自己的主题,则只需将
如果你需要一个钩子,它被称为 wp_head (查看 Codex 文档)。
If you are using your own theme, you can just put <style> tags in your header.php file pointing to the stylesheets you are using.
If you need a hook, it is called wp_head (check the Codex documentation on it).
对我有用的解决方案是使用输出缓冲区将 css 文件插入 head 中。
The solution that worked for me was inserting the css files in head using output buffer.