使用WordPress搭建的网站,用心写的文章,结果被人盗用,想必大家都有遇到过。今天我们来给自己的文章自动添加一段原创版权声明。这种简单功能,就不建议大家使用插件来实现。
- 首先进入WordPress的后台管理,找到外观,主题编辑器,找到模板函数 (functions.php)文件,并打开;
- 在模板函数 (functions.php)里面添加下面的代码,并选择更新文件。
//添加文章末尾版权信息 function copyright($content) { if(is_single()||is_feed()) { $content.='<div class="open-message" ><i class="fa fa-bullhorn"></i>版权所有,如未注明,均为原创,转载请注明<br/>本文链接:<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_permalink().'</a><br/>本文标题:<a rel="bookmark" title="'.get_the_title().'" href="'.get_permalink().'">'.get_the_title().' </div>'; } return $content; } add_filter ('the_content', 'copyright'); //添加文章末尾版权信息结束