This is how you expand the navigation in the WooCommerce customer account.

Marc Wag­ner

April 21, 2021

1 min read|

You can easi­ly extend the cus­to­mer account navi­ga­ti­on in Woo­Com­mer­ce, wit­hout any plug­in.

For this, we resort to woocommerce_account_menu_items and woocommerce_get_endpoint_url fil­ters.

First, we add a new end­point via the woocommerce_account_menu_items fil­ter. Here we set the dis­play­ed name (cus­tom menu) of the link and defi­ne a cus­tom end­point.

/**
 * add navigation items to woocommerce
 */
function addNavigationItemsToWooCommerce($items) {
   $items['custom-endpoint'] = __('Custom Menu');
   return $items;
}
add_filter('woocommerce_account_menu_items', 'addNavigationItemsToWooCommerce', 10, 1);

Then, of cour­se, we need to defi­ne a link for the end­point. For this, we use the woocommerce_get_endpoint_url fil­ter.

/**
 * add custom endpoint url
 */
function addNavigationItemsCustomEndpoint($url, $endpoint, $value, $permalink){
    if('custom-endpoint' == $endpoint){ 
       // set the url for our custom endpoint
       $url = get_permalink(1); 
    } 
   return $url;
}
add_filter('woocommerce_get_endpoint_url', 'addNavigationItemsCustomEndpoint', 10, 4);

With this, we have also alre­a­dy depo­si­ted a link for our end­point. Ide­al­ly, you store the new end­points in the backend of Word­Press and drag the sel­ec­ted post IDs from the­re. This way, you can chan­ge the links at any time wit­hout editing the PHP code.

Did you like the artic­le? Then lea­ve us a short com­ment.

88e86fcb816eff22bc917094df2862d8dd5c0e978b333e6dd5f36f808990c261 96

Arti­kel von:

Marc Wag­ner

Hi Marc here. I’m the foun­der of Forge12 Inter­ac­ti­ve and have been pas­sio­na­te about buil­ding web­sites, online stores, appli­ca­ti­ons and SaaS solu­ti­ons for busi­nesses for over 20 years. Befo­re foun­ding the com­pa­ny, I alre­a­dy work­ed in publicly lis­ted com­pa­nies and acqui­red all kinds of know­ledge. Now I want to pass this know­ledge on to my cus­to­mers.

Hast du eine Fra­ge? Hin­ter­lass bit­te einen Kom­men­tar