16 Responses

  1. The Frosty @WPCult
    The Frosty @WPCult June 24, 2009 at 11:27 am | | Reply

    That’s really awesome. Short and sweet!

  2. Adam W. Warner
    Adam W. Warner June 24, 2009 at 2:39 pm | | Reply

    Nice little trick Justin:)

  3. johnbillion
    johnbillion June 24, 2009 at 4:51 pm | | Reply

    Nice tip Justin. Will the visitor be automatically redirected to the single post or will they be returned back to the page where they entered the password?

  4. J Mehmett
    J Mehmett June 27, 2009 at 12:42 am | | Reply

    Hi, Justin. I had a comment on this topic with experimental code on it. It seems as your spam filter ate it again :(

  5. Danny
    Danny June 30, 2009 at 5:41 am | | Reply

    Hey Justin, is this code referred to WordPress 2.7? I ask you because in 2.8 it works without editing functions.php… Thanks in advance!

  6. J Mehmett
    J Mehmett July 1, 2009 at 12:37 am | | Reply

    Justin, I don’t know, why its not save to post a code in the comments area. It goes to the moderation queue or it gets eaten by Akismet :(

    Back to the comment, it was nothing but a possibility of replacing the default text with a friendly one in the excerpt instead of showing the login form.

    function excerpt_protected( $content ) {
    	if ( post_password_required() )
    		$content = "Hey, this is a password protected post, the admins of this blog are smart enough to check their loyal fans, so they decided to protect some certain content for the sake of goodness.";
    
    	return $content;
    }

    The above code replaces the default:

    There is no excerpt because this is a protected post.

    …with:

    Hey, this is a password protected post, the admins of this blog are smart enough to check their loyal fans, so they decided to protect some certain content for the sake of goodness.

  7. Danny
    Danny July 1, 2009 at 6:38 am | | Reply

    I’m sorry Justin, I have misunderstood your post!

  8. Samuel Secreto
    Samuel Secreto January 26, 2010 at 11:13 am | | Reply

    This is exacly watch I was watching to do in my blog,I was relly neeed of this feature!
    Thanks a lot and congratulations for your excellent blog!

  9. Dale
    Dale February 22, 2010 at 6:52 am | | Reply

    I don’t suppose anyone knows how to allow the excerpt to show on a protected post? Like a teazer…

  10. Marty
    Marty August 26, 2011 at 11:32 am | | Reply

    Just what I needed, thanks!

  11. Alicia
    Alicia September 13, 2011 at 1:34 pm | | Reply

    Thanks for sharing Justin.
    This is just what I need!!
    I will try this on my blog. :)

  12. cmegown
    cmegown March 5, 2012 at 10:42 pm | | Reply

    Is there a better way to do this now with v3.3.1? I tried this, and it ends up spitting out two password forms: one that is generated by the code above, and one that is generated by default. And yes, I am using the_excerpt.

    Thanks, and I hope to hear from you folks soon.

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.