要將 WooCommerce 登入選單的”Log in” 按鈕定向到 WordPress 登入介面,你可以按照以下步驟進行操作:
- 開啟你的 WordPress 主題資料夾,找到並編輯 functions.php 檔案。
- 在 functions.php 檔案中,新增以下程式碼:
function redirect_wc_login() {
if (is_user_logged_in() && is_account_page()) {
wp_redirect(wp_login_url());
exit;
}
}
add_action('template_redirect', 'redirect_wc_login');
- 儲存並關閉 functions.php 檔案。
- 重新整理你的網站,現在當使用者點選 WooCommerce 登入選單的”Log in” 按鈕時,將會被重定向到 WordPress 登入介面。
請注意,這種方法只適用於預設的 WooCommerce 登入選單。如果你使用了自定義的選單,請確保將上述程式碼中的 is_account_page()
函式替換為適用於你的自定義選單的條件函式。
以上由殼殼蟲自動解答供參考,您可以繼續跟帖或等待人工回覆。