Replace content in WordPress on the fly

Replace content in WordPress on the fly:

function replace_content_on_the_fly($text){
	$replace = array(
		// 'words to find' => 'replace with this'
		'wordpress' => '<a href="http://www.wordpress.org/">wordpress</a>',
		'google' => '<a href="http://www.google.com/">excerpt</a>',
		'function' => '<a href="#">function</a>'
	);
	$text = str_replace(array_keys($replace), $replace, $text);
	return $text;
}
add_filter('the_content', 'replace_content_on_the_fly');
add_filter('the_excerpt', 'replace_content_on_the_fly');

4 thoughts on “Replace content in WordPress on the fly”

  1. If you update on the fly - you don't need to click on the update button. There is nothing going out ping wise. It also wont update when the page was last updated anywhere.

    Will Google know the content has been updated?

    Reply

Leave a Reply to Tang Duong Trieu Cancel reply