Family Encyclopedia >> Electronics

How to Display Excerpts from Password-Protected Posts in WordPress

Password-protecting posts in WordPress is a great way to control access, but by default, it hides everything until the password is entered. Want to tease visitors with an excerpt? As experienced WordPress developers, we've tested these reliable methods to show excerpts from protected posts without compromising security.

How to Display Excerpts from Password-Protected Posts in WordPress

Method 1: Manually Display Excerpts with Custom Code

Add this code snippet to your child theme's functions.php file or a site-specific plugin for precise control.

function wpb_protected_excerpt( $excerpt ) {
    if ( post_password_required() ) {
        $post = get_post();
        $excerpt = $post->post_excerpt;
    }
    return $excerpt;
}
add_filter( 'the_excerpt', 'wpb_protected_excerpt' );

function wpb_protected_excerpt_posts( $content ) {
    if ( post_password_required() && is_single() ) {
        $post = get_post();
        return $post->post_excerpt . $content;
    }
    return $content;
}
add_filter( 'the_content', 'wpb_protected_excerpt_posts', 10 );

Edit your password-protected post in WordPress. Click Screen Options at the top, then check Excerpt to reveal the excerpt box below the editor.

How to Display Excerpts from Password-Protected Posts in WordPress

Enter your teaser text in the excerpt field.

How to Display Excerpts from Password-Protected Posts in WordPress

Ensure the post is password-protected, publish, and visit the front end. You'll see the excerpt displayed.

How to Display Excerpts from Password-Protected Posts in WordPress

Method 2: Use the Restrict Content Pro Plugin for Advanced Control

Password protection works for simple cases, but for multi-user sites or memberships, plugins offer superior flexibility and user management.

Install and activate Restrict Content Pro. Go to Restrict » Settings to customize the access-denied message, then save changes.

How to Display Excerpts from Password-Protected Posts in WordPress

In your post, add unrestricted teaser content first, then wrap protected sections in [restrict][/restrict] shortcodes. No need for WordPress's built-in password option.

How to Display Excerpts from Password-Protected Posts in WordPress

Tip: Use the Content Restriction box under the editor. Check it, select a user role like Subscriber, and logged-in users see everything—others get just the excerpt.

How to Display Excerpts from Password-Protected Posts in WordPress

Monetize with Premium Memberships

Restrict Content Pro supports paid memberships via Stripe, PayPal, or Braintree. Create tiered subscriptions to gatekeep premium content effectively.

How to Display Excerpts from Password-Protected Posts in WordPress

For more, check our guide on restricting content to logged-in WordPress users.

This approach has helped countless sites balance accessibility and exclusivity. Also explore our list of 40+ tools to manage and grow your WordPress blog.

Subscribe to our WordPress YouTube channel for video tutorials. Follow us on Twitter and Facebook.