有时候,写的有一些东西需要隐藏,但是又想分享给一些特定的人看,那么就用到了这个功能,密码可见
话不多说,上代码!
第一步,把下面的代码加入到你主题的functions.php里
function e_secret($atts, $content=null){ extract(shortcode_atts(array('key'=>null), $atts)); if(isset($_POST['e_secret_key']) && $_POST['e_secret_key']==$key){ return ' <div class="e-secret">'.$content.'</div> '; } else{ return ' <form class="e-secret" action="'.get_permalink().'" method="post" name="e-secret"><label>输入密码查看内容:</label><input type="password" name="e_secret_key" class="euc-y-i" maxlength="50"><input type="submit" class="euc-y-s" value="确定"> <div class="euc-clear"></div> </form> '; } } add_shortcode('secret','e_secret');
第二步,在编写文章的时候直接用短代码就行。
//使用的时候去掉# [#secret key="这里填密码"]这里写需要加密的内容[/#secret]
密码可见效果:
测试密码:54321
姊妹篇,回复可见
龙哥 发表于 1年前 (2021-04-06),共789字
版权声明:①欢迎转载但请注明出处。②如涉及版权联系(izhailong#qq.com)删除!
转载请注明:给wordpress文章页增加密码可见功能 || https://www.izhailong.com/371.html
本文由:版权声明:①欢迎转载但请注明出处。②如涉及版权联系(izhailong#qq.com)删除!
转载请注明:给wordpress文章页增加密码可见功能 || https://www.izhailong.com/371.html
暂无评论