
在WordPress中,Action能在指定位置执行指定的动作,而Filter则能将WordPress程序产生的数据进行“过滤”,达到“偷梁换柱”的目的。
实例:
1、在插件下创建demo.php,放入以下内容
<?php
/*
Plugin Name:测试插件
*/
function my_the_content_filter($content) {
return $content . '(在文章内容后面添加一段内容)';
}
add_filter( 'the_content', 'my_the_content_filter' );
?>
2、启用插件...