Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2281
    KeighDesign
    Member

    I need to hide the “private:” prefix in titles on password protected pages. I have found the following code that is supposed to be added to the theme functions.php file but cannot find where to add it without causing the site to crash. Here are the instructions found on WordPress.org and the code I need to add. It seems that the issue potentially arises from the fact that there is no end ?> on the functions file. Instructions found here.

    ———————-begin paste from wordpress.org———————-

     

    Assuming..

    ?>

    Is the last line in the file, replace that with..
    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'); ?>
    Or after should also be fine.. (like so)..
    ?> <?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'); ?>

    #2284
    KeighDesign
    Member

    Cancel this. I found a new plugin called WordPress Helpers that solved the issue for me. It allows the “protected” or “private” prefix to be hidden. Awesome stuff!

    Love this theme.

    Thanks.

    #2303
    Sakin
    Keymaster

    @KeighDesign: thanks and it’s great that the plugin helped you.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘functions.php’ is closed to new replies.