我正在尝试在wordpress的每一页中添加具有某些内容的div。为此,我正在尝试创建一个插件,以将该div添加到过滤器中。我已经创建了插件,用于修改内容的函数以及带有钩子“ the_content”的对该过滤器的调用:
function add_content_filter($content){
$original_content = $content ; // preserve the original ...
$add_pre_content = '<p> This will be added before the content..</p> ' ;
$add_sur_content = '<p> This will be added after the content..</p> ' ;
$content = $add_pre_content . $original_content . $add_sur_content ;
// Returns the content.
return $content;
}
add_filter('the_content', 'add_content_filter');
由于某些原因,即使激活了插件,插件也不会修改其内容。我使用了以下代码:
作为参考。为了使代码正常工作,我还需要做其他事情吗?
已解决,可能是由于托管插件中未更新的代码更改所致。它应该像这里写的那样工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句