-
Suppose you have a WordPress blog called "WordPress La", and then you change the blog name to "WordPress Bar". At this time, you will want to replace "WordPress" that appeared in previous articles with "WordPress." You may manually modify the articles one by one, or you may replace them through the MySQL database. The following code can help you quickly and accurately implement automatic replacement without logging into the database.
Open the function.php file and add the following code:
function replace_text_wps($text){ $replace = array( // 'Content before replacement' => 'Content after replacement' 'wordpress' => '<a href="#">wordpress</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_content', 'replace_text_wps');
Save the file. success!
Code source
Article source: WordPress