• Posted: 2010-10-05
  • Author: Filip Stefansson
  • Tags:

Remove Private/Protected from Post Title

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
<?php
function the_title_trim($title) {
	$title = attribute_escape($title);
	$findthese = array(
		'#Protected: #', // Notice the blank space after Protected:
		'#Private: #' // Notice again, otherwise the title get pushed.
	);
	$replacewith = array(
		'', // What to replace "Protected: " with
		'' // What to replace "Private: " with
	);
	$title = preg_replace($findthese, $replacewith, $title);
	return $title;
}
add_filter('the_title', 'the_title_trim');
?>

Instructions:

This snippet removes the description before the post title when a post’s visibility is either Password protected or Private.

If your language is not english, you should replace Protected & Private (as seen in the code below), with the correspondent words in the language you are using.


Related links:
http://css-tricks.com/snippets/wordpress/remove-privateprotected-from-post-titles/
Share this snippet

If you like this snippet, share it with friends!