X

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.

Instructions:

All you have to do is add this code to any of your theme’s template file or in a site-specific plugin:

<?php
          wp_login_form();
?>

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 );
wp_login_form($args);
?>

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. Thanks!

  2. 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.

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

    Just what I was looking for! Thank you.

  4. Thanks

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

Add a Comment

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!