WooCommerce: Add New Tab in My Account Page (Custom Endpoint)

How to Add a New Tab @ WooCommerce My Account Page
function bbloomer_add_premium_support_endpoint() {
    add_rewrite_endpoint( 'my-ads', EP_ROOT | EP_PAGES );
}
  
add_action( 'init', 'bbloomer_add_premium_support_endpoint' );
  

// 2. Add new query var
  
function bbloomer_premium_support_query_vars( $vars ) {
    $vars[] = 'my-ads';
    return $vars;
}
  
add_filter( 'query_vars', 'bbloomer_premium_support_query_vars', 0 );
  

// 3. Insert the new endpoint into the My Account menu
  
function bbloomer_add_premium_support_link_my_account( $items ) {
    //$items['my-ads'] = 'My Ads';

	$myitems = array('my-ads' => 'My Ads');
	
//position 
	$items = array_slice( $items, 0, 1, true ) +   $myitems +   array_slice( $items, 1, count( $items ), true );
	
    return $items;
}
  
add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_premium_support_link_my_account' );
  

// 4. Add content to the new tab
  
function bbloomer_ads_content() {
   echo '<h3>Your ads</h3>';'
   
   echo 'your content';
   
}
  
add_action( 'woocommerce_account_my-ads_endpoint', 'bbloomer_ads_content' ); 
After adding this woocommerce custom end point in my account page. Please save the permalinks again Enjoy!

Share this post:

Amitpal Singh
Amitpal Singh
Freelance website and application developer. Working from Sangrur Punjab in India.
Follow Amitpal on:

Register

Create your account and post ad

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.