在版权意识越来越来淡薄的今天,很多站长都喜欢打小抄,不注重别人的成果。Copy别人的文章,连内容出处都不注明,相信各位看官都有遇到过,对此事也比较头疼。在文章当中添加内容版权只能说是防君子不防小人,但却能小小的提示和警告作用,以影响部分站长。下面Sky就简单介绍下版权的添加方法。
本博之前方面内容页添加版权是通过修改single.php模板来实现的,Feed版权是通过插件来实现的。在博客程序日益臃肿的情况下,插件实现的方式越来越不可取,所以Sky以直在探求可行的解决办法。今天这个方法可以同时解决文章页面和Feed页页的版权插入的问题,还可以去掉原因用的插件。见代码:
function allcopyright($content) {
if(is_single() or is_feed()) {
$content.= '<div style="margin-top: 10px; padding-top: 5px; border-top: 1px dotted rgb(77, 77, 77);">原文标题:<a rel="bookmark" title="'.get_the_title().'"
href="'.get_permalink().'">'.get_the_title().'</a></div>';
$content.= '<div>原文链接:<a rel="bookmark" title="'.get_the_title().'" href="'.get_permalink().'">'.get_permalink().'</a></div>';
$content.= '<div>订阅本站:<a href="http://feed.feedsky.com/sinsky"target="_blank">http://feed.feedsky.com/sinsky</a> 转载请注明来源,如果喜欢本站可以Feed
订阅本站。</div>';
}
return $content;
}
add_filter ('the_content', 'allcopyright');
上面这段代码可以在文章输出的时候将代码回到文章底部,所以Feed也是同时有版权的,这样多多少少会减轻WP不少压力吧!效果见本博和本博Feed。
<div style="margin-top: 10px; padding-top: 5px; border-top: 1px dotted rgb(77, 77, 77);">
OK,今天收工。