Site icon Catch Themes

functions.php

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'); ?>
Exit mobile version