I have a separate theme for my custom WP install that will be use for mobile users, in my case I need to change an html tag in all the excerpt instances but without altering the DB, I found this simple function that would be perfect but I can't get it to work, nothing's happening.
function replace_content_on_the_fly($text){
$replace = array(
// 'words to find' => 'replace with this'
'<p>' => '<div>',
'</p>' => '</div>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_excerpt', 'replace_content_on_the_fly');
I added the above code in my theme function.php
. Why doesn’t it work?