I’m trying to add some string replacements to the_title() –
function format_title($content) {
$content = str_replace('&','&<br>', $content);
$content = str_replace('!','!<br>', $content);
return $content;
}
add_filter('the_title','format_title',11);
When I try and replace ampersands I get an additional “#038;” after the replacement (ASCII for ampersand), I’m not sure as to why this occurs (security reason?) or how to create a workaround. I’ve tried replacing “&” with “& amp ;” but with no effect.
The goal is to add line breaks at certain points of a title to create a better flow in the typography.
Both the database and the site has UTF8 encoding.