• Resolved Kanashimi

    (@kanashimi)


    I’m attempting to remove the “Private:” from Private Posts on my blog, but I’m not sure where to edit this. If I can’t remove it, I’d very much like to edit it so it says “Fanatic Content”. If anyone knows how I can do this I would be very thankful!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Rather than editing core files, you might be better off making the changes at the bottom of the functions.php file located in your present theme. The method described in this thread still works perfectly for me in WordPress 3.0.1. All credit for the code goes to t31os.

    Short version:

    paste this at the bottom of functions.php in your current theme directory and replace the obvious with what you want it to say.

    <?php
    function the_title_trim($title)
    {
      $pattern[0] = '/Protected:/';
      $pattern[1] = '/Private:/';
      $replacement[0] = ''; // Enter some text to put in place of Protected:
      $replacement[1] = ''; // Enter some text to put in place of Private:
    
      return preg_replace($pattern, $replacement, $title);
    }
    add_filter('the_title', 'the_title_trim');
    ?>
    Thread Starter Kanashimi

    (@kanashimi)

    Whoops, for some reason inserting this into my functions made this error appear when searching for posts in the admin panel:

    Warning: Cannot modify header information – headers already sent by (output started at /home/istalk/website/918thefan/wp-content/themes/91.8 The Fan/functions.php:279) in /home/istalk/website/918thefan/wp-includes/pluggable.php on line 890

    I entered the following into the code:

    <?php
    function the_title_trim($title)
    {
      $pattern[0] = '/Protected:/';
      $pattern[1] = '/Private:/';
      $replacement[0] = 'Protected'; //
      $replacement[1] = 'Fanatic Content -'; //
    
      return preg_replace($pattern, $replacement, $title);
    }
    add_filter('the_title', 'the_title_trim');
    ?>

    Needs to go at the very end of the file, after the closing php tag, or within the existing php tags, with no tags of its own. Follow the comments in the thread I linked to for all of the details.

    If you just want to remove it completely, there is a plugin that might do it for you. One person has confirmed that it works with WP version 3.0.1
    Might be worth a try.
    FT Remove Private From Post Titles

    Thread Starter Kanashimi

    (@kanashimi)

    I put it at the very end, which I thought was weird and tried some different placement, but got the same error.

    Regardless, the plugin worked, and I’m thankful for the help. ??

    Glad it worked out!

    Another way is to hook just the protected_title_format and/or private_title_format filters (tested this in WP3.x):

    add_filter('protected_title_format', create_function('$ptf','print "Fanatic Content: Protected";'));
    add_filter('private_title_format', create_function('$pvf','print "Fanatic Content: Private";'));
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Removing Or Changing "Private"’ is closed to new replies.