I have a WordPress CMS website where most labels are needed to be white. So the theme includes the below styles per form labels.
.login label {
color: #fff;
font-size: 14px;
}
This above style is populated from within /wp-login.php file — the style itself is located in the login.min.css (which is included directly within wp-login.php)
I need to override this ONLY for the forget password screen.
Luckily there are custom ID selectors for the two labels I need to be black in this instance. #pass1 #pass2
My problem is, I have NO ACCESS to /wp-login.php
and login.min.css
— I have tried adding !important
and declaring these two selectors within header.php
but they were not read.
I need to somehow add; with current permission situation.
#pass1 { color: #000 !important; }
#pass2 { color: #000 !important; }
Could I use jQuery from header.php
or footer.php
to append the style? Would it be read?
It’s not best practice to edit any wp core files, so I’d advice not to touch wp-login.php anyway, since updating WordPress can reset things.
Instead, add this to your functions.php:
Since the login and forgot password screens are not theme dependent, your
header.php
file will not be read, so any styles you put in there won’t affect these pages.Add this to your
template.php
fileand then add your custom styles to
style-login.css
login_head
andlogin_enqueue_scripts
are called one after another, so it doesn’t matter which one you’re using…Using
wp_enqueue_style
is the best practice but it can beecho '<link rel="stylesheet" ...>';
without problem.I’m adding a solution because this isn’t the kind of code that you just drop onto your theme
functions.php
. We want to keep the code running even if we swap themes. So a functionality plugin comes handy:Check the following to learn about the Heredoc sintax used to build the
$CSS
string: What is the advantage of using Heredoc in PHP ?