Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Updated Sunday, February 22nd, 2009 at 8:20pm

Show the Intro to Password Protected Posts in WordPress

This is a small hack for WordPress that allows you to show the first part of password protected posts. It will display the content you have before the ‘more’ tag, followed by the standard password box. I wrote this up for a member of the WordPress forum, and I thought I would share it here. Update: Instructions are now provided for WordPress 2.2

Before you begin

The instructions below have been verified in WordPress versions 2.0 through 2.8. The only difference between these versions is the file you have to edit.

Instructions

For WordPress 2.0 or 2.1, open /wp-includes/template-functions-post.php

For WordPress 2.2 through 2.8+, open /wp-includes/post-template.php

Find the following text:

$output = get_the_password_form();
return $output;

Replace it with this:

$content = $pages[$page-1];
$content = explode('<!--more-->', $content, 2);
$output = "";
$output .= $content[0];
$output .= get_the_password_form();
return $output;

This next step is optional, but I think it makes it nicer.

In the get_the_password_form function, find the following text (may vary between versions):

This post is password protected.

And replace it with this:

The rest of this post is password protected.

Or whatever text you would like it to show.

  If you have found this page useful, please consider donating. Thanks!

Pages: [7] 6 5 4 3 2 1 » Show All

  1. I love what you guys are up too. This kind of clever work and exposure!

    Keep up the superb works guys I’ve added you guys to our blogroll.

  2. We’re a group of volunteers and starting a new scheme in our community. Your site offered us with valuable info to work on. You’ve
    done a formidable job and our whole community will be thankful
    to you.

  3. Its the main mostly different things to be used in data storage also Visit my site

    Regards :- Juliet Bocala

  4. The only difference between these versions is the file you have

  5. Hi there this is kinda of off topic but I was
    wondering if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding experience so I wanted to get guidance from someone with experience. Any help would be enormously appreciated!

    Here is my web-site :: buy traffic

  6. I’m truly enjoying the design and layout of your website. It’s a
    very easy on the eyes which makes it much more enjoyable for me to come here and
    visit more often. Did you hire out a designer to create your theme?
    Exceptional work!

    Also visit my web site … how to get traffic to my website

  7. Pretty! This was an extremely wonderful post. Thank you for supplying
    these details.

  8. It is perfect time to make a few plans for the longer term
    and it’s time to be happy. I have learn this publish and if I may I want to counsel you few fascinating issues or tips. Perhaps you could write next articles referring to this article. I want to learn even more issues approximately it!

  9. Fruit Handle is newbie please help me for this code ? hanks

  10. Intro to password seems to be useful. Thanks!!

  11. for a variety of dispersed equipmentNike Canada Store

  12. I need it!

  13. I need it!

Pages: [7] 6 5 4 3 2 1 » Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.