Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WordPress replaces the excerpt of a password-protected post with the message “There is no excerpt because this is a protected post.” To show a useful teaser instead, add a the_excerpt filter in a custom plugin. If visitors should unlock the post without leaving the archive, return WordPress’s password form from that filter instead.

What WordPress shows by default

When a post is protected with a password, WordPress does not normally expose its excerpt before the password is accepted. Calls that generate the excerpt return the protected-post message: “There is no excerpt because this is a protected post.” This behavior is different from a post set to Private; password-protected content is intended for visitors who can supply the password.

Option 1: Replace the message with a custom excerpt

This approach keeps password entry on the protected post’s page while displaying your own teaser, explanation, or call to action in an archive, home page, or query listing.

Add the filter in a custom plugin

Create a PHP file in a site-specific plugin (for example, wp-content/plugins/site-protected-excerpts/site-protected-excerpts.php) and activate it from Plugins → Installed Plugins. A custom plugin keeps the change when you switch themes or update the theme.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php
/**
 * Plugin Name: Site Protected Excerpts
 */

add_filter( 'the_excerpt', 'site_protected_excerpt' );

function site_protected_excerpt( $excerpt ) {
    if ( post_password_required() ) {
        return '<p>This article is available to members with the post password. Open the article to enter it.</p>';
    }

    return $excerpt;
}

The callback checks post_password_required() and changes the filtered output only for a protected post. The replacement may contain HTML, but return it rather than printing it.

Use the post’s manually written excerpt

If you want editors to control the teaser from the post editor, read the stored excerpt inside the protected branch and provide a fallback when it is empty:

add_filter( 'the_excerpt', 'site_protected_manual_excerpt' );

function site_protected_manual_excerpt( $excerpt ) {
    if ( ! post_password_required() ) {
        return $excerpt;
    }

    $manual = get_post_field( 'post_excerpt', get_the_ID() );

    return $manual
        ? wpautop( esc_html( $manual ) )
        : '<p>This post is password protected. Enter the password to continue.</p>';
}

Choose either callback, not both, unless you deliberately combine their behavior.

Option 2: Put the password form in the listing

If the desired flow is “enter the password here,” replace the excerpt with the HTML returned by get_the_password_form():

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
add_filter( 'the_excerpt', 'site_protected_excerpt_form' );

function site_protected_excerpt_form( $excerpt ) {
    if ( post_password_required() ) {
        return get_the_password_form();
    }

    return $excerpt;
}

WordPress supplies its standard protected-post form, including any password-form customizations already applied elsewhere on the site. This function returns form HTML; it does not print the form by itself.

Replacing the form yourself

If you replace the returned form with custom markup, retain a password input limit of 20 characters. WordPress saves only the first 20 characters because of database constraints.

return '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post">
    <label for="post-password">Password</label>
    <input name="post_password" id="post-password" type="password" maxlength="20" required>
    <input type="submit" value="Unlock">
</form>';

Returning the form is important: echoing it inside the filter can produce duplicate or misplaced output.

Make sure the template actually displays excerpts

A filter cannot change a listing that never calls an excerpt function. Check the active home, archive, search, or Query Loop template.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • In a block theme, edit the relevant template and confirm that the Post Excerpt block is present inside the Query Loop.
  • In a classic theme, look for the_excerpt() or get_the_excerpt() in the loop used by that page.
  • If the template uses the_content(), a custom card component, or a theme-specific summary field instead, the the_excerpt filter may not affect it.

After activating the plugin, clear any page, object, or CDN cache and test both a protected post and a normal post.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Protect related data, not just the excerpt

WordPress prevents protected post content and the normal excerpt from being shown before the correct password is entered. It does not automatically protect values that a theme or plugin prints from custom fields. Guard any private custom-field output explicitly:

if ( ! post_password_required() ) {
    echo esc_html( get_post_meta( get_the_ID(), 'private_teaser', true ) );
}

Do not describe an excerpt as a secure teaser if the same text is exposed through custom fields, REST output, a related-post component, or another unguarded rendering path.

No-code alternative: a protected-excerpt plugin

The WordPress.org listing for PPWP – Password Protect Pages advertises a setting to show excerpts of password-protected content. This is an option if you prefer plugin settings over PHP. Review its current documentation and test it with the active theme: the listing does not establish compatibility with every theme or template.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the visitor experience

Goal Use What visitors see
Explain what is behind the lock Custom text in the the_excerpt filter A teaser or instruction in the listing; password entry remains on the post page
Let visitors unlock from the archive get_the_password_form() in the filter The password form directly in the listing
Avoid custom code PPWP’s advertised protected-excerpt setting Depends on the plugin and the template’s excerpt support

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.