首页 » 遗忘 » 正文内容
2年前 寻梦xunm 553 遗忘

IMG_20210920_073653.jpg
首先在模板的 functions.php 文件里添加如下代码:

//文章版权申明
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、在模板中的管理文章的php文件,比如 single.php 或post.php中的文章底部

由于我是子比主题,在比如<?php zib_single_content() ?>后面添加如下代码

其他主题请自行测试
[hide]

<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>

[/hide]
下面代码加入自定义css代码中
[hide]

/*文章版权*/
.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
}
/*文章版权结束*/

[/hide]
效果图如上面展示效果 内容自己修改

文章来源:https://52ql.cn/249.html

0 赞 or 打赏
喜欢就打赏一点
微信 支付宝
已有0 条评论,0 个点赞
隐私

Q Q:1340326824

vipshiyi@qq.com

QQ群:422720328

生活所迫,再见了苦逼的BUG们,以后有缘在会吧。