添加文章登陆可见功能
添加文章登陆可见功能,将下面的代码添加到你主题的functions.php
文件下。
//登陆可见 function login_hide($atts, $content){ $atts = shortcode_atts( array(), $atts, 'loginh' ); if(is_user_logged_in()){ $cont = '<p>'.do_shortcode($content).'</p>';//登陆后调用登陆可见内容 }else{ $cont='请登陆';//未登陆提示内容 } return $cont; } add_shortcode('loginh','login_hide');
后台使用
编辑文章时转为文本模式,插入下面短代码即可(将【】
转为[]
)
【loginh】这里放你想要登陆后可见的内容【/loginh】