WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Removing Or Changing "Private" (7 posts)

  1. Kanashimi
    Member
    Posted 3 years ago #

    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!

  2. ClaytonJames
    Member
    Posted 3 years ago #

    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');
    ?>
  3. Kanashimi
    Member
    Posted 3 years ago #

    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');
    ?>
  4. ClaytonJames
    Member
    Posted 3 years ago #

    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

  5. Kanashimi
    Member
    Posted 3 years ago #

    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. :)

  6. ClaytonJames
    Member
    Posted 3 years ago #

    Glad it worked out!

  7. David Sader
    Member
    Posted 3 years ago #

    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";'));

Topic Closed

This topic has been closed to new replies.

About this Topic