Replace words in your wordpress posts
Let your Wordpress blog was named “portfolio” and you renamed it “myportfolio”. Then don’t edit your xxx posts to replace every single occurence! With this very useful code will do it for you, like a magic!
Just put words to replace in the array on line 4. Once done, paste the code into your function.php file, save the file, and you're ready!
function replace_text_wps($text){
$replace = array(
// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
'portfolio' => 'myportfolio',
'excerpt' => 'excerpt',
'function' => 'function'
);
$text = str_replace(array_keys($
replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');
Let your Wordpress blog was named “portfolio” and you renamed it “myportfolio”. Then don’t edit your xxx posts to replace every single occurence! With this very useful code will do it for you, like a magic!
Just put words to replace in the array on line 4. Once done, paste the code into your function.php file, save the file, and you're ready!
function replace_text_wps($text){
$replace = array(
// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
'portfolio' => 'myportfolio',
'excerpt' => 'excerpt',
'function' => 'function'
);
$text = str_replace(array_keys($
return $text;
}
add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');
No comments:
Post a Comment