WordPress wp_lostpassword_url() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
URL helper

Definition

In WordPress, wp_lostpassword_url() returns the URL of the lost password page, where users can ask for a password reset email.

It is useful for a custom login form. Add a "Forgot your password?" link next to it.

Syntax

It returns a string, so wrap it in esc_url().

WordPress
<?php
echo esc_url( wp_lostpassword_url() );
CallWhat it does
wp_lostpassword_url()The lost password page address.
wp_lostpassword_url( home_url() )Go to the home page after the reset.
wp_lostpassword_url( get_permalink() )Return to this page afterwards.

The page it points to is part of the normal login screen.

Full declaration
WordPress
wp_lostpassword_url( string $redirect = '' ): string

Parameters

ParameterDescription
$redirectstring. The page to open after the reset. Default is empty.

Return Value

Return ValueDescription
stringThe lost password URL, with redirect_to when you pass one.

WordPress Examples

Three short theme examples. Each one shows the code and what it prints.

Example 2 — With a redirect

Send users to the home page afterwards.

WordPress
<?php echo esc_url( wp_lostpassword_url( home_url() ) ); ?>

How It Works

  1. The first argument is the next page.
  2. It is added as redirect_to.
  3. Use it when you build your own flow.

Example 3 — Next to a login form

Show the form and the link together.

WordPress
<?php if ( ! is_user_logged_in() ) : ?>
  <?php wp_login_form(); ?>
  <p><a href="<?php echo esc_url( wp_lostpassword_url() ); ?>">Lost password?</a></p>
<?php endif; ?>

How It Works

  1. Guests see the login form.
  2. Under it we add the reset link.
  3. Logged-in users see neither.

Frequently Asked Questions

It returns the URL of the lost password page as a string.
No. It only returns the URL. Write the link tag yourself.
It sets the page to open after the reset is finished.
No. Add the link yourself with wp_lostpassword_url().

Next: wp_meta()

Run the wp_meta action so plugins can add items to the Meta list.

wp_meta() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful