1. Home
  2. Docs
  3. Woocommerce Basic
  4. 마이어카운트에 탭 메뉴 & 콘텐츠 추가

마이어카운트에 탭 메뉴 & 콘텐츠 추가

마이어카운트 페이지에 메뉴와 콘텐츠를 추가하고자 할 때

/**
 * @snippet  Add Custom Page in My Account
 */
// add menu link
add_filter ( 'woocommerce_account_menu_items', 'oks_log_history_link', 40 );
function oks_log_history_link( $menu_links ){	
    $menu_links = array_slice( $menu_links, 0, 2, true ) 
    + array( 'my-tab' => '마이탭' )
    + array_slice( $menu_links, 2, NULL, true );	
    return $menu_links;
}
// register permalink endpoint
add_action( 'init', 'oks_add_endpoint' );  
function oks_add_endpoint() {
    add_rewrite_endpoint( 'my-tab', EP_PAGES );
}
// content for the new page in My Account, woocommerce_account_{ENDPOINT NAME}_endpoint
add_action( 'woocommerce_account_my-tab_endpoint', 'oks_my_account_endpoint_content' );
function oks_my_account_endpoint_content() {
    // of course you can print dynamic content here, one of the most useful functions here is get_current_user_id()
    echo 'Last time you logged in: yesterday from Safari.';
}