Want to replace some words on the fly on my website.
$content = preg_replace('/bWordb/i', 'Replacement', $content);
That works so far. But now i want only change the the words which are inside
div id=”content”
How do i do that?
Want to replace some words on the fly on my website.
$content = preg_replace('/bWordb/i', 'Replacement', $content);
That works so far. But now i want only change the the words which are inside
div id=”content”
How do i do that?
You must be logged in to post a comment.
use
the_content
filter, you can place it in your themesfunction.php
fileUPDATE: This applies only if you are using WordPress of course.
If the content is dynamically driven then just echo the return value of
$content
into the div with id of content. If the content is static then you’ll have to either use this PHP snippet on the text then echo out the return into the div, or use JavaScript (dirty method!).