Home  >  Article  >  CMS Tutorial  >  How to batch modify article text in wordpress

How to batch modify article text in wordpress

尚
Original
2019-07-13 13:26:472420browse

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.

How to batch modify article text in wordpress

#2. Open the theme’s functions.php file.

How to batch modify article text in wordpress

3. Add the following code to the theme’s functions.php file:

function replace_text_wps($text){  
    $replace = array(  
        // '关键词' => '替换的关键词'  例如:
        &#39;wordpress&#39; => &#39;<a href="#">wordpress</a>&#39;,  
        &#39;excerpt&#39; => &#39;<a href="#">excerpt</a>&#39;,  
        &#39;function&#39; => &#39;<a href="#">function</a>&#39;  
    );  
    $text = str_replace(array_keys($replace), $replace, $text);  
    return $text;  
}  
  
add_filter(&#39;the_content&#39;, &#39;replace_text_wps&#39;);  
add_filter(&#39;the_excerpt&#39;, &#39;replace_text_wps&#39;);

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn