作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 wordpress 的新手,想知道从已安装和激活的插件中添加 css 的最佳方法。我有一个名为“social-media
”的激活插件,在该插件中我创建了一个名为“social-login-style.css
”的 css 文件
我想包含
这个css文件并应用样式
到我的内容。我应该如何在任何页面中添加 css 文件,以便我可以看到效果。
简而言之,我想在 wp-login.php
文件中添加 social-login-style.css
。
最佳答案
无论是主题还是插件,css还是js,任何自定义添加,wp_enqueue_scripts
都是你唯一需要的acton。
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
function additional_custom_styles() {
/* Enqueue The Styles */
wp_enqueue_style( 'custom-login-style', plugins_url( 'social-login-style.css', __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'additional_custom_styles' );
如果您只在登录屏幕上添加它,请使用以下条件,
if ( $GLOBALS['pagenow'] === 'wp-login.php' ) {
// We're on the login page!
}
希望这对您有所帮助:)
更新
请检查login_enqueue_scripts
。它旨在仅将自定义脚本添加到登录页面。无需任何登录条件即可正常工作。
https://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts
关于css - 从激活的 WordPress 插件应用 CSS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48031936/
我是一名优秀的程序员,十分优秀!