Like we all know, WordPress is the most promising publishing platform, it’s free and easy to tweak or installed new themes or plugin. Or if we have little bit knowledge in PHP Programming we can enhanced our WordPress more easily. On this example from WPSnipp, we will show you How To Replace Words in Your WordPress posts easily.
This tutorial need to edit your functions.php, because this code do some add_filter to make it works.
All need to do, open your functions.php and paste this code.
function replace_text_wps($text){
$replace = array(
// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
'wordpress' => '<a href="#">wordpress</a>',
'domain' => '<a href="#">domain</a>',
'excerpt' => '<a href="#">excerpt</a>',
'function' => '<a href="#">function</a>'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
add_filter('the_excerpt', 'replace_text_wps');
On the code above using add_filter to filter the_content and the_excerpt. So all match words will be replace with the new parameter as described. That’s is, we hope this tutorial works on you. Thanks Kevin Chard from WP Snipp for this code
Images from http://www.flickr.com/photos/42931449@N07/5418402840/




Pingback: The Best way to replace words in your posts | Jhez3R