the content – Using str_replace on the_content and the_excerpt, but not working on archive index pages

Question

I am using code like this to replace a string in my posts.

function replace_text($text) {
$text = str_replace('look-for-this-string', 'replace-with-this-string', $text);
$text = str_replace('look-for-that-string', 'replace-with-that-string', $text);
return $text;
}
add_filter('the_content', 'replace_text');
add_filter('the_excerpt', 'replace_text');

This is working great, except on my archive index pages. On these pages, the text is not being replaced. What am I missing?

0
McFarnell 1 month 2022-08-25T19:40:09-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse