I'm designing a custom login template and I need a way to access the <input> html so I can add a label inside the input. I understand the use of wp_login_form() but that only lets me set the default lables outside the input to blank. I need to add the onfocus and onblur attributes to the html. Any ideas?

1 Answer 1


There's this basic trick: Close brackets, open again, insert what you need, close again.

Real life example:

$args = array( 
    // some args for the login form
    'value_username' => 'User Name" onBlur="whatever" onFocus="anotherfoo';
wp_login_form( $args );

So we closed the brackets after the Username, then added our additional attributes and left the quotes open at the end, so the wp_login_form() function can then close it by itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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