Ich versuche, bei bestimmten Wörtern auf meiner Website die Farbe in Rot zu ändern. Der folgende Code ändert jedoch jedes Wort in "Array".
Kann mir jemand sagen, was mit meinem Code nicht stimmt?
function replace_content($content)
{
$newwords = array("Check", "Map", "Comments", "Send", "Print");
$content = str_replace($newwords, '<span style="color:red">' . $newwords . '</span>', $content);
return $content;
}
add_filter('the_content','replace_content');
function replace_content($text) {
$replace = array(
'Check' => '<span style="color:red">Check</span>',
'Map' => '<span style="color:red">Map</span>',
'Comments' => '<span style="color:red">Comments</span>',
'Print' => '<span style="color:red">Print</span>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content','replace_content');