登出後重定向
預設情況,在WordPress登出後會重定向到登入頁(wp-login.php),但開發WordPress網站時,有時候我們希望登出後可以回到首頁或網站上某一頁,我們可以透過下列代碼達成,把下列代碼貼到主題目錄下的functions.php中就可以了。
functions.php預設路徑:
/wp-content/themes/{主題名稱}/functions.php
登出後重定向至首頁:
/**
* v123 DEV
* https://v123.tw
*/
add_action('wp_logout','auto_redirect_after_logout');
function auto_redirect_after_logout(){
wp_redirect( home_url() );
exit();
}登出後重定向指定網址:
/**
* v123 DEV
* https://v123.tw
*/
add_action('wp_logout','auto_redirect_external_after_logout');
function auto_redirect_external_after_logout(){
wp_redirect( 'https://v123.tw' );
exit();
}
you’re actually a good webmaster. The web site loading velocity is incredible.
It kind of feels that you’re doing any distinctive
trick. Also, The contents are masterpiece. you have performed a great
process on this subject!