超级简单,在 functions
加入下面代码,然后发布文章的时候就可以用短代码来调用
//会员查看内容 function login_to_read($atts, $content=null) { extract(shortcode_atts(array("notice" => ' <h4>该段内容只有登录才可以查看</h4> <div class="article-login hidden-sm"> <div class="ruike_user-wrapper"> <span class="ruike_user-loader"> <a href="'.site_url('/login').'" class="signin-loader z-bor">登录</a> <b class="middle-text"><span class="middle-inner">or</span></b> </span> <span class="ruike_user-loader"> <a href="'.site_url('/reg').'" class="signup-loader l-bor">注册</a></span> </div> <i class="up-new"></i> </div> '), $atts)); if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) return $content; return $notice; } add_shortcode('userreading', 'login_to_read');