Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在wordpress中查找和替换单词_Php_Wordpress - Fatal编程技术网

Php 如何在wordpress中查找和替换单词

Php 如何在wordpress中查找和替换单词,php,wordpress,Php,Wordpress,我正在开发一个用于查找和替换单词的插件。到目前为止,我有这个代码,它似乎不工作 function replace_content($content){ $wp_post = get_the_content(); $content = str_replace('lorem',' ronny',$wp_post); return $content; } add_filter('the_content','replace_content'); 非常感谢您的帮助。找到了解决方

我正在开发一个用于查找和替换单词的插件。到目前为止,我有这个代码,它似乎不工作

function replace_content($content){

   $wp_post = get_the_content();

   $content = str_replace('lorem',' ronny',$wp_post);

   return $content;

}
add_filter('the_content','replace_content');

非常感谢您的帮助。

找到了解决方案。内容是大写的,所以我使用了
str\u ireplace()
而不是
str\u replace()
函数来忽略大小写。

请定义
它似乎不起作用
它似乎没有执行所需的任务。搜索和替换。这不是定义。他的意思是,什么是预期的输出,什么是实际的输出/错误消息/除了“它不工作”以外的任何东西。代码实际上应该在内容中搜索单词lorem,并用ronny替换它。到目前为止还没有。@Ronny如果你删除了
$wp_post=get_the_content()和使用的
$content=str_replace('lorem','ronny','content')