WordPress: Password protecting a post

Setting a posts visability

On the WordPress post editor screen, on the right hand side click the edit link labelled Visibility Show Below.

png

A Radio list should appear with three options on it:

  1. Public – visible to anyone
  2. Password protected – Once you have typed a password only people who know the password can view it.
  3. Private – Visible to anyone who has a membership on the website.

Once a post has been set to Password protected or Private, WordPress will prefix the title with either Private: or Protected.

Remove Private: and Protected: from the_title

This can easily be removed from the title by adding a wordpress filter to the_title,

Insert the following snippet into your themes functions.php file to remove Protected: and Private: from your post titles.

<?php
add_filter( 'the_title', 'jc_remove_title_state' );
function jc_remove_title_state($title){
	$title = preg_replace( array('#Protected:#', '#Private:#'), '', $title);
	return $title;
}
?>


Liked this article? help spread the word.