使用 Woocommerce 登錄時,有沒有辦法僅在登錄“模式”的索引頁面上呈現儀表板選單?
我只想在“儀表板”上顯示它。不在“訂單”、“下載”、“地址”或其他頁面上。
我不想用 CSS 來做。
我已經復制了模板檔案,所以我將發布儀表板和訂單模板。
儀表盤.php
https://github.com/woocommerce/woocommerce/blob/master/templates/myaccount/dashboard.php
訂單.php
https://github.com/woocommerce/woocommerce/blob/master/templates/myaccount/downloads.php
uj5u.com熱心網友回復:
您可以使用woocommerce_account_navigation動作鉤子,而不是對模板檔案進行更改
所以你得到:
function action_woocommerce_account_navigation () {
// Detect the WC Dashboard page, and if NOT
if ( is_user_logged_in() && is_account_page() && is_wc_endpoint_url() ) {
// Remove navigation
remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' );
}
}
add_action( 'woocommerce_account_navigation', 'action_woocommerce_account_navigation', 1, 0 );
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/323228.html
標籤:WordPress的 求购
