免插件实现WordPress文章页底部防采集版权信息
这里介绍两种方法,分别是通过修改主题文件的singer.php文件和functions.php文件实现的,两种方法都可以使用
1.在singer.php文件里添加代码,在singer.php文件里找到这样一段代码:
<?php the_content(); ?>
这就是文章主题了,在他后面添加下面的代码:
<p>转载原创文章请注明,转载自:<strong><?php bloginfo('name'); ?></strong>[<a href="<?php echo get_settings('home'); ?>"><?phpechoget_settings('home'); ?></a>]</p><p>本文链接: <a href="<?php the_permalink() ?>"title="<?php the_title(); ?>"><?php the_permalink(); ?></a></p>
这样每篇文章都会自动的加上版权信息。
2.通过在functions.php文件里添加代码:在functions.php里面合适位置添加如下代码:
/** RSS Feed copyright */
function feed_copyright($content) {
if(is_single() or is_feed()) {
$content.= "<blockquote>";
$content.= '<div>
» 转载保留版权:<a title="秦唐网" href="http://blog.ui90.com">秦唐网</a>
» <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 title="订阅秦唐网" href="http://feed.feedsky.com/qintag">
点此订阅本站</a></div>';
$content.= "</blockquote>";
}
return $content;
}
add_filter ('the_content', 'feed_copyright');
强烈建议使用第二种。
来自胖子马博客