Create new tab under my account woocommerce frontend

create new tab under my account woocommerce frontend

In this article I will show you how you can add new tabs with content in woocommerce user account page without any plugin. there are several plugins which can do this thing in very easy way, but they makes the website slow. So I'm going to use add_rewrite_endpoint function to add new tabs under my account page.
Use below code to add new tabs under woocommecre my account. Here I will add two new tabs gallery and categories.

Adding Tabs

function my_custom_woocommerce_tabs() {
    add_rewrite_endpoint( 'gallery', EP_ROOT | EP_PAGES );
    add_rewrite_endpoint( 'categories', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_woocommerce_tabs' );

Assign templates for new added tabs

 

function my_custom_woocommerce_tabs() {
    include 'woocommerce/myaccount/gallery.php'; 
include 'woocommerce/myaccount/category.php'; } add_action( 'woocommerce_account_gallery_endpoint', 'my_custom_woocommerce_tabs' );

 

Hi, I'm Saurav, the developer behind usingphp. Donate to help me keep usingphp free and maintained.

Please let me know what your thoughts or comments are on this article. If you have any suggestion or found any mistake in this article then please let us know.

Latest Comments

Add your comment