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')代码>