WooCommerce PHP Advanced Requires WooCommerce

Add a Custom Tab to My Account

Add a new page to WooCommerce's My Account area, such as Support or Rewards, with its own menu item and URL.

Tested on WordPress 7.1 PHP 8.3 Updated
functions.php 24 lines
// 1. Register the endpoint: /my-account/support/.
add_action( 'init', function (): void {
	add_rewrite_endpoint( 'support', EP_ROOT | EP_PAGES );
} );

// 2. Add it to the menu, just before Log out.
add_filter( 'woocommerce_account_menu_items', function ( array $items ): array {
	$logout = $items['customer-logout'] ?? null;
	unset( $items['customer-logout'] );
	$items['support'] = 'Support';
	if ( $logout ) {
		$items['customer-logout'] = $logout;
	}
	return $items;
} );

// 3. Print the content.
add_action( 'woocommerce_account_support_endpoint', function (): void {
	echo '<h2>Support</h2>';
	echo '<p>Need help with an order? Email us at <a href="mailto:help@example.com">help@example.com</a> and include your order number.</p>';
} );

// 4. Give the page a title.
add_filter( 'woocommerce_endpoint_support_title', fn () => 'Support' );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

My Account is where logged-in customers already go, which makes it a good place for support info, loyalty points or custom content. This snippet adds a new tab with its own URL.

How it works

An endpoint is the part after /my-account/, like /my-account/orders/. add_rewrite_endpoint() registers a new one called support. The menu filter adds it just above Log out, and WooCommerce automatically calls woocommerce_account_support_endpoint to print its content. The last filter sets the page title.

Replace support in every line with your own endpoint name.

Things to watch

  • After adding the snippet, go to Settings → Permalinks and click Save Changes once, to refresh the URL rules. Otherwise the new tab shows a 404.
  • For a rich page, read the content from a normal WordPress page with apply_filters( 'the_content', get_post_field( 'post_content', $page_id ) ).

How to test it

Visit Settings → Permalinks and save, then log in as a customer. A Support tab should appear above Log out and open /my-account/support/.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only