Enqueue new login style sheet

时间:2017-08-11 作者:Magnus Pilegaard

我尝试将一个名为login\\u styles的新登录样式表排队。css。

这是我使用的代码:

function my_logincustomCSSfile() {
    wp_enqueue_style(\'login-styles\', get_template_directory_uri() . \'/login_styles.css\');
}
add_action(\'login_enqueue_scripts\', \'my_logincustomCSSfile\');
将其放置在“我的孩子”主题函数中。php。

css文件完全为空。我该怎么办?

该文件与函数放在同一文件夹中。php

1 个回复
最合适的回答,由SO网友:birgire 整理而成

代替get_template_directory_uri(), 这是父主题的目录,带有get_stylesheet_directory_uri() 因为您希望将文件作为子主题目录中的目标。

或者更好的是,使用get_theme_file_uri( \'login_styles.css\' ) 如果要搜索它,请首先在子主题的目录中,否则在父主题的目录中。

结束

相关推荐

如何将wp-login.php页面上的默认css样式出列?

我正在wp登录上加载自己的样式表。php页面使用login_enqueue_scripts 所以我不需要该页面附带的默认样式。是否可以取消与wp登录相关的样式。php?在WordPress的其他地方,我使用wp_dequeue_style() 删除与一起排队的CSS文件wp_enqueue_style(). 我不确定wp登录的过程是否相同。php。