我的所有排队样式也应用于后端。我以前从未遇到过这种行为。
这是我的代码:
wp_register_style( \'main-styles\', get_stylesheet_directory_uri() . \'/css/styles.css\', false, \'1.0.0\', \'all\');
wp_enqueue_style(\'main-styles\');
我的所有排队样式也应用于后端。我以前从未遇到过这种行为。
这是我的代码:
wp_register_style( \'main-styles\', get_stylesheet_directory_uri() . \'/css/styles.css\', false, \'1.0.0\', \'all\');
wp_enqueue_style(\'main-styles\');
为什么我的风格被应用到管理领域?
假设这就是所有的代码,这是因为您正在将样式全局排队。你需要把它挂到wp_enqueue_scripts
, 仅在前端加载。
wp_register_style( \'main-styles\', get_stylesheet_directory_uri() . \'/css/styles.css\', false, \'1.0.0\', \'all\');
function enqueue_script_front_wpse_84975() {
wp_enqueue_style(\'main-styles\');
}
add_action(\'wp_enqueue_scripts\', \'enqueue_script_front_wpse_84975\');
您可以全局注册或wp_register_scripts
内部零件enqueue_script_front_wpse_84975
功能,但您需要挂钩wp_enqueue_style
, 至少,到wp_enqueue_scripts
或者将样式表排到所有位置。我意识到将样式表放在以“script”结尾的挂钩上似乎很奇怪,但是that is correct per the Codex.wp_enqueue_style
可以是,也可以是,用于在任何位置排队,无论是前端还是后端,正如您在Codex页面上看到的admin_enqueue_scripts
你把这些挂在哪里?
如果你看看codex, 您应该将这些添加到函数中,并将函数挂钩到wp_enqueue_scripts
用于前端显示。
示例:
function add_my_css(){
wp_register_style( \'main-styles\', get_stylesheet_directory_uri() . \'/css/styles.css\', false, \'1.0.0\', \'all\');
wp_enqueue_style(\'main-styles\');
}
add_action(\'wp_enqueue_scripts\', \'add_my_css\');
我的wordpress已经被黑客攻击了2到3次。如何提高其安全性?重命名index.php 在里面wp-admin 目录