WORDPRESS文章中微信打赏功能的2种实现方法


本文整理自网络,侵删。

本文实例讲述了WORDPRESS文章中微信打赏功能的2种实现方法。分享给大家供大家参考,具体如下:

打赏功能功能就是给我们一些资助了,写博客不容易所以会给一些内容与说明了,下面我们就一起来看2种给WORDPRESS文章添加微信打赏功能实现方法.

方法一、比较专业也是比较复杂了

给WordPress文章添加微信打赏功能,如果你的博文给别人有帮助,也许会有热心的读者给你打赏,首先在WordPress主题的functions.php末尾添加如下代码.

代码如下:
//如果是文章页并且不是手机访问,在文章末尾添加一段html代码
function add_pay($content) {
$pay = <<<PAY
<div class="gave" >
<a id="gave">打赏</a>
<div class="code" id="wechatCode" style="display: none">
<img src="/wp-content/uploads/2015/10/pay.jpg" alt="">
<div><img src="m/wp-content/uploads/2015/10/ico-wechat.jpg" alt="微信logo" class="ico-wechat">微信扫一扫,打赏作者吧~</i></div>
</div>
</div>
PAY;
if(is_single() && !wp_is_mobile()){
$content .= $pay;
}
return $content;
}
add_filter( 'the_content', 'add_pay',10);

这个函数的作用是:如果是文章页并且不是手机访问,在文章末尾添加一段html代码.

在主题的css文件添加以下样式:

代码如下:
<style type="text/css">
.gave {
height: 110px;
position: relative;
text-align: center;
}
.gave .code::after {
border-color: #fff transparent transparent;
border-style: solid;
border-width: 10px;
content: "";
height: 0;
left: 50%;
margin-left: -7.5px;
position: absolute;
top: 100%;
width: 0;
}
.gave .code {
background: #fff none repeat scroll 0 0;
border-radius: 5px;
bottom: 100%;
box-shadow: 0 0 15px #e5e5e5;
color: #68b3de;
display: none;
font-size: 13px;
height: 160px;
left: 50%;
margin-left: -110px;
padding: 20px;
position: absolute;
width: 180px;
}
.gave a {
background: #f06363 none repeat scroll 0 0;
border-radius: 50%;
color: #fff !important;
display: inline-block;
font-size: 18px;
height: 75px;
line-height: 75px;
text-align: center;
width: 75px;
text-decoration: none;
}
.gave .code > img {
height: 124px;
width: 124px;
border: medium none;
max-width: 100%;
}
</style>

阅读剩余部分

相关阅读 >>

30 个很棒的php开源cms内容管理系统小结

wordpress(wp)3.5版修改默认上传图片路径的解决方法

wordpress中短代码失效解决办法

wordpress在iis下伪静态后子目录无法访问的解决方法

wordpress博客添加mp3播放器

wordpress后台的内容管理功能

wordpress开发中用于标题显示的相关函数使用解析

制作个性化的wordpress登陆界面的实例教程

利用fix rss feeds插件修复wordpress的feed显示错误

wordpress实现文章支持和反对功能的方法

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...