这种方式适合VIP会员,会员要注册登录才能访问,而注册需要邀请码,可以出售邀请码,就变成了VIP会员可以访问隐藏的内容。
在主题模板函数 functions.php的<?php下边添加代码实现。
// 添加只允许登录后查看 add_shortcode( 'members_only', 'members_only_shortcode' ); function members_only_shortcode( $atts, $content = null ) { if ( is_user_logged_in() && !empty( $content ) && !is_feed() ) { return $content; } $a= '<center><span> <div style="text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:green;">要查看更多文章内容,请您先<a href="http://www.zw1.net/wp-login.php" target="_blank">登录/注册</a> </div> </span></center>'; return $a; }
在需要加密的内容头底加入下边两段代码(html编辑器中加入),就会提示只有登录后才能访问隐藏内容,你就等着卖VIP赚大钱把。
[members_only] 这里的内容只为已登录的用户显示的 [/members_only]
效果如图:
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)