以下是内容和函数的筛选器示例:
function the_content_replacer($content)
{
//global $post, $posts;
//$content = str_replace(']]>', ']]>', $content);
$content .= "\n<div style=\"display:none;\">text here</div>";
//$content = preg_replace('/="http:\/\/cnn/i',
// '="http://example.com?http://cnn', $content, -1);
return $content;
}
add_filter('the_content', 'the_content_replacer', 1);
-
关于此筛选器的更多示例
http://wordpress.stackexchange.com
..........
-
您只需复制并粘贴主题中文件“functions.php”中的内容就可以了。
-
如果运行multisite,也可以将它放到wp content/mu plugins目录中,这样它就可以在多站点环境中的所有博客上工作。
-
第三个参数确定应用筛选器时的重要性,请参见:
https://wordpress.stackexchange.com/questions/2126/at-what-priority-does-add-filter-overwrite-core-functions
-->最好将所有WordPress问题发布到
http://wordpress.stackexchange.com网站
!!!
-->如果您使用例如。
$content .= "\n<div style=\"display:none;\">text here</div>";
它不会删除结束段落标记(请注意字符串开头的换行符)