Skip to content


为wordpress复制文章时自动加版权


给wordpress博客内容加版权网上还没有现成的插件,不过个人认为wordpress最好的地方就是源码可以随便修改,从后台主题编辑就行,相信这也是很多网友选择wordpress的原因吧。

给文章加版权分两种,一种是在文章上方或下方显示你的版权声明,这种方法可以加以下代码

    <p>转载原创文章请注明,转载自:<strong><?php bloginfo(‘name’); ?></strong>[<a href="<?php echo get_settings('home'); ?>"><?php echo get_settings('home'); ?></a>]</p>  <p>本文链接: <a href=”<?php the_permalink() ?>” title=”<?php the_title(); ?>”><?php the_permalink(); ?></a></p>那到底应该放到什么地方呢? 找到single.php(单篇文章页),找到类似下面的这样一句话: <?php the_content(); ?>

这句话中,the_content(); 这个函数调用的就是文章整篇内容。关键是找到这个函数,把前面那段代码,放到这行代码的后面就可以了。需要注意的是,请保持所有标签按照正确的顺序进行开启和关闭。

还有一种形式,大家可以根据自己的喜好选择  这个代码加的时候也是打开Single.php, 找到<?php the_content(); ?>,再后面加上
<p>
<a href="http://creativecommons.org/licenses/by/3.0/deed.zh">版权声明</a>:转载时请以超链接形式标明文章原始出处和作者信息</br>本文链接:
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_permalink(); ?></a>
</p>

第二种方法是在网友复制你网站内容的时候自动版权,大家可以试着复制下我的文章试下,就是这种效果,给大家代码

<script type=”text/javascript”>
document.body.oncopy = function () {
setTimeout( function () {
var text = clipboardData.getData(“text”);
if (text) {
text = text + “\r\n本文来自: 启光博客(www.iewb.net) 详细出处参考:”+location.href; clipboardData.setData(“text”, text);
}
}, 100 )
}
</script>

这个代码网友们放到footer.php的最下面就可以。

相关文章

所属分类 技术文章.

文章标签 .

原创文章转载请注明,转载自:启光博客[http://www.iewb.net]

原文链接: http://www.iewb.net/index.php/qg/167.html


2 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. 小兵传奇 评论

    这个收藏了,现在人太不地道,这个也只能给君子用,小人还是防不住地,对于小人加了版权声明也不管用

  2. 两性健康 评论

    复制的时候加版权好,感觉第一个没怎么有用,现在的人都不看这个了



欢迎点评

or, reply to this post via trackback.