Display WordPress Login Form Anywhere with wp_login_form

Snippets by IsItWP

Are you looking for a way to add a simple login form anywhere on your website? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display WordPress login form anywhere with wp_login_form.


All you have to do is add this code to any of your theme’s template file:


If you’re looking for a more advanced login snippet that includes custom fields and options, then you can use this code snippet.

<?php $args = array(
        'echo' => true,
        'redirect' => 'http://wpsnipp.com',
        'form_id' => 'loginform',
        'label_username' => __( 'Username' ),
        'label_password' => __( 'Password' ),
        'label_remember' => __( 'Remember Me' ),
        'label_log_in' => __( 'Log In' ),
        'id_username' => 'user_login',
        'id_password' => 'user_pass',
        'id_remember' => 'rememberme',
        'id_submit' => 'wp-submit',
        'remember' => true,
        'value_username' => NULL,
        'value_remember' => false );

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 25 must have WordPress plugins and how to easily switch from Squarespace to WordPress.

Comments  Leave a Reply

  1. How do we make it so that the login disappears after they’ve logged in?

    1. Michela Durazzi May 10, 2019 at 4:13 pm

      You can use:
      if ( !is_user_logged_in() )

  2. Thanks!

  3. Dart No Frills May 18, 2017 at 3:51 am

    Hi, i am Marco from Italy. I have an other question, my wp site has install qtranslate plugin, and when includ wp_login_form in my header.php file work only in default language version (en_EN). Do you have any ideas? Thanks.

  4. Web design Cheshire May 9, 2017 at 4:35 am

    Just what I was looking for! Thank you.

  5. Thanks

  6. How do i make it so it includes the Lost Password link? how do i include an ARG in the

Add a Comment Cancel reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[60% OFF Today!]
[60% OFF Today!]
[10% OFF Today!]
[10% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]