WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp login url

Contents

Description

This Template Tag returns the URL that allows the user to log in to the site.

Usage

 <?php echo wp_login_url$redirect ); ?> 

Parameters

$redirect
(string) (optional) URL to redirect to on login. Must be absolute (as in, http://example.com/mypage/). Recommended: site_url( '/mypage/ ' ).
Default: None

Examples

Default Usage

<a href="<?php echo wp_login_url(); ?>" title="Login">Login</a>

Login and Redirect to Current Page

<a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>

Login and Redirect to Homepage

<a href="<?php echo wp_login_url( home_url() ); ?>" title="Login">Login</a>

Notes

Change Log

Since: 2.7.0

Source File

wp_login_url() is located in wp-includes/general-template.php.

Related

Login Tags: is_user_logged_in(), wp_login_form(), wp_loginout(), wp_logout(), wp_register()
Login URLs: wp_login_url(), wp_logout_url(), wp_lostpassword_url(), wp_registration_url()

See also index of Function Reference and index of Template Tags.