2014-12-05 68 views
0

我正在爲德國的一家丹麥船運代理公司製作一個Wordpress網站,他們希望主頁將字母「ø/Ø」自動轉換爲字母「ö/ Ö」。在整個Wordpress頁面中用另一個字母替換一個字母

我已經做了一個PHP函數/程序,我從$ string中將ø/Ø替換爲ö/Ö。

但是,如何才能讓它檢查Wordpress頁面中的所有字母?

<?php 
$string = "Öýra Bibendum Trisö tique agergöet dellentesque Öibendum Öristique gmet reölentesqueö."; 
$newSmall = "ö"; 
$oldSmall = "ø"; 
$onlyconsonants = str_replace($oldSmall, $newSmall, $string); 
$newLarge = "Ö"; 
$oldLarge = "Ø"; 
$onlyconsonants = str_replace($oldLarge, $newLarge, $onlyconsonants); 

echo $onlyconsonants; 

?> 
+0

快速:javascript來替換字母......但要小心hrefs。 – Dez 2014-12-05 21:51:57

回答

0

有兩種方法可以做到這一點:

1.使用插件(可能是最好的方式):

看看this one可以爲你做的工作。

它描述爲:

讓你有所發現,網頁,職位,自定義文章類型和 與GUI丟棄的物品替換文本。可選:postmeta和LOW_PRIORITY更新

2.更換的數據庫

這個查詢應該做的伎倆內容:

UPDATE wp_posts SET post_content = REPLACE ( 
post_content, 
'Item to replace here', 
'Replacement text here'); 

完全教程here

做一個備份在任何過程之前。

相關問題