释放双眼,带上耳机,听听看~!
[wm_tips]这个和评论回复可见的初衷一样,将作者的这个功能腾出来做付费之类的选择[/wm_tips]
教程如下:依然在functions.php文件里添加如下代码即可搞定:
//部分内容登录可见 function login_to_read($atts, $content=null) { extract(shortcode_atts(array("notice" => '<div style="text-align:center;border:1px dashed #0395f6;padding:8px;margin:10px auto;color:#000000;border-radius: 5px; <span style="color: red;"><i class="b2font b2-face"></i>温馨提示<i class="b2font b2-face"></i> </span>此处内容需要<a title="登录后可见" href="#respond">登录</a>后才能查看! </div>'), $atts)); if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) return $content; return $notice; } add_shortcode('hide', 'login_to_read'); //添加按钮 add_action('after_wp_tiny_mce', 'my_quicktags'); function my_quicktags($mce_settings) { ?> <script type="text/javascript"> QTags.addButton( 'login', '登录可见', '{hide}', '[/hide]' ); function my_quicktags() { } </script> <?php }
[wm_warn]提示:在18行代码处,将{}换成[][/wm_warn]