Forums

how to password-protect content, not teaser (3 posts)

  1. Nevioth
    Member
    Posted 6 years ago #

    Is there any way to password-protect the full entry content, but display the teaser/excerpt freely?

    I tried looking it up but couldn't find anything.

    Thanks in advance

  2. valentine
    Member
    Posted 6 years ago #

    Seconding this request.

  3. Kafkaesqui
    Moderator
    Posted 6 years ago #

    Would take a bit of coding to accomplish. But yep, can be done. Here's one way:

    Replace

    <?php the_content(); ?>

    in your template with

    <?php
    if(!empty($post->post_password)) :

    if(stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password) :
    $teaser = explode('<!--more-->', $post->post_content, 2);
    echo apply_filters('the_content', $teaser[0]);
    echo get_the_password_form();
    else :
    echo apply_filters('the_content', $post->post_content);
    endif;

    else :
    the_content();
    endif;
    ?>

    Yeah, a little complicated...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags