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: [3] 2 1 » Show All

  1. 38
    Nick

    hey, i don’t know how to use the file and everything. i tried putting it into the url and it doesn’t show me the page. could you email me soon? thanks for your help! (:

  2. 37
    Mari

    i’m confused, what’s this file we’re supposed to open? i’ve tried adding the /wp-includes/post-template.php to the url but that doesn’t work. could you drop me an email at russmsoh@gmail.com please? thanks! :)

    not a very good computer person if you haven’t noticed. :D

  3. We supply all kinds of moncler boots,moncler bags,moncler coats,moncler jackets,moncler T-shirt,moncler vest and so on.We have got a good reputation pf our products with top quality and good price.We sincerely look forward to futher cooperation with you for mutual benefits.We are sure that you will find working with us is a pleasant, time-saving and profitable experience. Please feel free to contact us if you have any questions.Our website is http://www.newlyapparel.com.

  4. thank u so much!

  5. I am able to get it to work with WP 2.92, please send me an email or leave your email I can send you the modified file.

  6. Is there a way to do this in WP 2.9.x? I just tried and couldn’t find the file containing that bit of code. I would love to get this working.

    Thanks.

  7. Great post, will do this asap. Thank you for the tip.

    Regards,
    Peter Trape

  8. I’ve tried the combinations above and ended up with this
    $returns = mysql_query($query);
    $result = mysql_fetch_row($returns);
    $post_title = $result[5];
    $post_excerpt = $result[7];
    It worked for a while and now it only displays the title twice :(
    Any help please?
    Andrew

Pages: [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.