WordPress.org

Forums

[resolved] Changing the form text on password protected entries (8 posts)

  1. mixvio
    Member
    Posted 8 years ago #

    I'm trying to find an answer about this but no luck.

    On http://joshuameadows.com/2006/04/drama-already/ you can see that the entry is password protected.

    I want to change the text of "This post is password protected. To view it please enter your password below:" to something else, but I can't seem to find any place to do this. It's not in my theme as far as I can tell and I couldn't find it going through the .php files. Any ideas?

  2. It's in the template-functions-post file. However, editing it directly is not a particularly good idea (though it will work). A better way would be to recognize it in a filter on "the_content" and change it there. You can do this in a functions.php in a theme, or you can do it in a plugin. You'd do it like so:

    function change_pw_text($content) {
    $content = str_replace(
    'This post is password protected. To view it please enter your password below:',
    'New text goes here:',
    $content);
    return $content;
    }
    add_filter('the_content','change_pw_text');

    An even better way would be to create your own language file, which will let you replace any of the built-in text in WordPress, however that is more complex than a simple quick solution.

  3. mixvio
    Member
    Posted 8 years ago #

    Thanks for the advice Otto, however I'm incredibly obtuse. :p Is there any way I can convince you to walk me through how to do said functions.php? I don't know enough about WordPress yet to do this myself.

  4. Look in your theme's directory.
    If there's no functions.php, create a new text file with that name and insert the following code into it (no blank lines before or after the code!!).
    If the file does exist, then just edit it with a text editor and add this code to it (minus the <?php and ?> lines).

    <?php
    function change_pw_text($content) {
    $content = str_replace(
    'This post is password protected. To view it please enter your password below:',
    'New text goes here:',
    $content);
    return $content;
    }
    add_filter('the_content','change_pw_text');
    ?>

    Change the "New text goes here:" to whatever you want it to be.

  5. mixvio
    Member
    Posted 8 years ago #

    Thanks so much! This worked perfectly.

  6. 3stripe
    Member
    Posted 8 years ago #

    I've followed these instructions and created a functions.php file in my template with the change_pw_text($content) function...

    It doesn't seem to have any effect though? Am I missing something else?

  7. 3stripe
    Member
    Posted 8 years ago #

    I got it fixed in the end :)

  8. rondelw
    Member
    Posted 7 years ago #

    Why is this "This post is password protected. To view it please enter your password below:" coming up? How do I get rid of it so there's no password protection? I think it comes up when I edit a post from an RSS feed...is that the case? Anyone....

Topic Closed

This topic has been closed to new replies.

About this Topic