Site logo

Archived topic

Adding php snippet

3 replies · Started by Dee Broughton on September 24, 2020

Viewing posts 1–4 of 4

I read the article about adding a php snippet and took the advice to use the Code Snippets plugin, and copied what I think is the code, but it's still not doing anything. Is there another step I'm missing somewhere?

http://www.dee.email/OPEN/SimPics/snippet.jpg

Hi Dee,

You can filter the title output by using the the_title filter.

You can try this out.

add_filter('the_title', 'line_break_title');
function line_break_title($title) {
	$title = str_replace(' | ', '<br />', $title);
	return $title;
}

Let us know if it works for you.

Thank you, Elvin! I don't actually understand why it needs a filter, but it worked great. Thank you very much! :)

I believe the snippet you were using was supposed to be used for the_title() function inside your content.php.

Something like this.

the_title( echo str_replace(' | ', '<br />', get_the_title()) );

the_title() function is used to control the title output. Since we went the plugin route, we had to filter what the content.php outputs rather than editing its code.

This archived topic is closed to new replies.