i tried to enqueue a new login stylesheet called login_styles.css.

This is the code i have used:

function my_logincustomCSSfile() {
    wp_enqueue_style('login-styles', get_template_directory_uri() . '/login_styles.css');
add_action('login_enqueue_scripts', 'my_logincustomCSSfile');

Its placed in my child-themes functions.php.

The css file is totally empty. How do i go about this?

The file is placed in same folder as functions.php


Replace get_template_directory_uri(), that's for your parent theme's directory, with get_stylesheet_directory_uri() since you want to target the file within the child theme's directory.

Or better yet, just use get_theme_file_uri( 'login_styles.css' ) if you want to search for it, first in the child theme's directory, else in the parent theme's directory.

  • That get_theme_file_uri() was something I was looking for a long time. Gracious be!
    – Jack Johansson
    Aug 11 '17 at 15:38
  • 1
    yes it's handy, more flexible and I like that it takes the file name as an input argument.
    – birgire
    Aug 11 '17 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.