下面總結了兩種關于WordPress中批量替換正文程序代碼,一種是在mysql數據庫中直接使用replace替換,另一種是修改functions函數來進行操作.
在 WordPress 主題的 functions.php 中插入以下代碼:
- function content_str_replace($content = ''){
- $content = str_replace('old', 'new', $content);
- return $content;
- }//開源軟件:Vevb.com
- add_filter('the_content', 'content_str_replace', 10);
和之前一樣,其中 old 是舊的字符串,new 是你要替換的文字.
運行 SQL,輸入以下語句即可:
UPDATE wp_posts SET post_content = replace(post_content, 'old', 'new');
其中 old 是舊的字符串,new 是你要替換的文字.
新聞熱點
疑難解答
圖片精選