在主题模板函数 functions.php的<?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="post-password-form" action="'.get_permalink().'" method="post" name="e-secret"><p><label for="pwbox-142">输入密码查看 <input type="password" name="e_secret_key" size="20" /></label> <input type="submit" class="euc-y-s" value="→_→" /></p>
</form>
';
}
}
add_shortcode('secret','e_secret');
可任意修改加密密码,适不同场景
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。