Home > Article > CMS Tutorial > How to batch modify article text in wordpress
We often add some key phrases to WordPress blog articles, but later we want to replace these phrases with other content for various reasons. Manual replacement is a lot of work, and it is troublesome. Easy to miss. The following experience can help you replace these key phrases very conveniently.
1. First log in to the WordPress backend. Open template editing.
#2. Open the theme’s functions.php file.
3. Add the following code to the theme’s functions.php file:
function replace_text_wps($text){ $replace = array( // '关键词' => '替换的关键词' 例如: '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_excerpt', 'replace_text_wps');
For more wordpress-related technical articles, please visit wordpress Learn in the tutorial column!
The above is the detailed content of How to batch modify article text in wordpress. For more information, please follow other related articles on the PHP Chinese website!