//template_redirect动作钩子是一定会执行的,所以用这个钩子对全站有效
add_action( ‘template_redirect’, ‘ashuwp_show_only_login’, 0 );
function ashuwp_show_only_login(){
//判断登录
if( !is_user_logged_in() ){
auth_redirect(); //跳转到登录页面
exit();
}
}
标签: Wordpress
wordpress禁用后台登录页语言切换选项
add_filter( ‘login_display_language_dropdown’, ‘__return_false’ );
wordpress添加登录注册界面的背景图片,修改登录注册框在界面右上角
function custom_loginbg() {
echo ‘<style type=”text/css”>
body{background: url(‘.get_bloginfo(‘template_directory’).’/img/login_bg.jpg) center center no-repeat;background-size: cover;}
#login{position:fixed;right:5%;padding: 2% 0 0;}
.login #nav{font-size:16px;}
.wp-core-ui .button-group.button-large .button, .wp-core-ui .button.button-large {height: 35px;width: 100%;margin: 10px auto;line-height: 32px;padding: 0 12px 2px;}
#backtoblog a{font-size: 16px;}
.login #nav, .login #backtoblog {text-shadow: none;float: right;margin: 0 31px 0 31px;padding: 16px 0px 0 0px;}
</style>’;}
add_action(‘login_head’, ‘custom_loginbg’);
在对应的主题目录下设置图片