从规范的角度看,我们在WordPress内容页面底部应该需要放我们文章的版权信息。有些主题是自带的,如果没有自带,我们可以用插件实现,或者可以选择麦子这里提供的2个办法选择一个实现,可以自动实现WordPress内容页的版权功能。
1、自动添加
add_filter ('the_content', 'fanly_copyright');
function fanly_copyright($content) {
global $post;
if((get_post_meta($post->ID,'original',true)||get_post_meta($post->ID,'Fanly_Submit',true)=='Original') && (is_single() or is_feed())) {
$content.= '<p>除非注明,否则均为<a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('name').'</a>本站原创文章,转载必须以链接形式标明本文链接</p>';
$content.= '<p>原文链接:<a title="'.get_the_title().'" href="'.get_permalink().'" target="_blank">'.get_permalink().'</a></p>';
}
return $content;
}
2、手动添加
这个我们需要添加到当前的主题 Single.php 文件中。
<br>
<div class="post-copyright">
<div class="iconfont-copyright">
<i class="fa fa-flag-o" aria-hidden="true"></i>
</div>
<p>
<span>本文作者:<?php the_author(); ?></span>
</br>
<span>原文链接:<a href="<?php the_permalink();?>" title="<?php the_title(); ?>"><?php the_permalink();?></a></span>
<br>
版权声明:<a href="http://creativecommons.org/licenses/by/3.0/deed.zh" target="_blank">知识共享署名-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)</a>协议进行许可
<br>
转载时请以超链接形式标明文章原始出处和作者信息
</p>
</div>
添加到合适的内容下面。同时还需要添加CSS。
/*文章版权*/
.post-copyright {
margin-bottom:20px;
margin-top:20px;
border-radius:13px;
padding:20px;
color:#666;
background-color:#f8f8f8;
line-height:1.5em;
position:relative
}
.iconfont-copyright {
position:absolute;
top:-10px;
left:13px;
font-size:20px;
background:#f8f8f8;
color:#666;
border-radius:100%;
text-align:center;
line-height:24px;
padding:2px;
height:30px;
width:30px;
border:1px solid #f8f8f8
}
/*文章版权结束*/
样式可以根据实际需要修改。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END