WordPress: Change the default text for password protected pages

13 Mar
2010

Edit functions.php of your template and paste in this

// Password Protected Page Message
function custom_password_form($form) {
  $subs = array(
    '#<p>This post is password protected. To view it please enter your password below:</p>#' => '<p>Hopefully this works.</p>',
    '#<form(.*?)>#' => '<form$1 class="passwordform">',
    '#<input(.*?)type="password"(.*?) />#' => '<input$1type="password"$2 class="text" />',
    '#<input(.*?)type="submit"(.*?) />#' => '<input$1type="submit"$2 class="button" />'
  );

  echo preg_replace(array_keys($subs), array_values($subs), $form);
}

add_filter('the_password_form', 'custom_password_form');

3 Responses to WordPress: Change the default text for password protected pages

Avatar

Wordpress Password-Protected Posts

June 7th, 2010 at 12:21 am

[...] code you need to add is explained in a blog post by Peter [...]

Avatar

Christian Louboutin

June 8th, 2010 at 8:01 pm

I enjoy reading the report, too. It′s easy to understand that a journey like this is the biggest event in ones

life.

Avatar

Belix

November 26th, 2010 at 9:34 pm

Hi Christian,

Thanx for the post.

Great job. Kudos!

Cheers

Comment Form

top

Switch to our mobile site