2014-12-05 70 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

做一个备份在任何过程之前。

相关问题