本文实例讲述了WordPress实现登录或退出后直接跳转回首页的方法。分享给大家供大家参考。具体分析如下:
现在Wordpress是登录之后跳回到我们上次查看的页面,那么要如何修改它登录之后直接跳回到首页呢,这里就来给给大家详细介绍一下解决方法.
首先定位到登录链接所在位置,你会看到类似下面的代码:
<a href="<?php echo wp_login_url(); ?>" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";">
复制代码
代码如下:
<a href="<?php echo wp_login_url(home_url()); ?>" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";">
复制代码
代码如下:
<a href="<?php echo wp_login_url(get_permalink()); ?>" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";">
复制代码
代码如下:
<a href="<?php echo wp_logout_url(home_url()); ?>" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";">
复制代码
代码如下:
<a href="<?php echo wp_login_url(get_permalink()); ?>" style="margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";">
复制代码
代码如下:
function back_curPageURL() {
$pageURL = 'http';
if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" )
$pageURL .= "s";
$pageURL .= "://";
if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" )
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
else
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
return $pageURL;
}
add_filter('login_redirect', ' back_curPageURL ');
把上述代码加到function.php文件中即可。
希望本文所述对大家的WordPress建站有所帮助。