通过WordPress 短代码实现将文章中的部分内容隐藏,通过关注微信公众号自动回复获取验证码,实现公众号的粉丝零突破,哈哈哈。
将下面的代码,添加到当前主题函数模板 functions.php 文件中:
//公众号获取验证码
function weixin_fans($atts, $content=null){
extract(shortcode_atts( array (
'key' => null,
'reply' => ''
), $atts));
// 管理员登录直接显示隐藏内容
if ( current_user_can('level_10') ) {
return '<div class="hidden-content">'.do_shortcode( $content ).'</div>';
}
// 输入正确验证码显示隐藏内容
if(isset($_POST['weixin_key']) && $_POST['weixin_key']==$key){
return '<div class="hidden-content">'.do_shortcode( $content ).'</div>';
} else {
return '
<form class="post-password-form weixin-form" action="'.get_permalink().'" method="post">
<div class="weixin-box">
<div class="post-secret"></i>获取高速下载链接</div>
<p>
<input style="width:120px;height:26px;" type="password" size="18" name="weixin_key">
<input style="width:40px;height:30px;" type="submit" value="提交" name="Submit">
</p>
<div class="weixin-secret">
<div class="weixin-w">回复<span class="weixin-n">'.$reply.'</span>将会获取<span class="weixin-n">验证码</span></div>
<img src="https://defcon.cn/wp-content/uploads/2020/07/qrcode.jpg" alt="weixin">
</div>
</div>
</form>';
}
}
add_shortcode('weixin', 'weixin_fans');
记得修改为你的公众号名称
CSS样式,可自行修改调试
.hidden-content, .weixin-form {
padding: 20px 0.5rem;
border: 2px dashed #e63b3f;
margin-top: -40px;
}
.weixin-form img {
width: 140px;
float: right;
margin-top: -126px;
margin-right: -3px;
}
.weixin-n {
color: #e63b3f;
}
使用方法:
微信公众平台后台添加关键词回复即可,如题:安利一款,小姐姐推荐的BT磁力搜索软件:http://pan.defcon.cn/file/1855579-452826001