Woocommerce

Add New My Account Page With Custom Endpoint

We will see how we can add a custom endpoint to my account page in front means one new our own page like order, download, etc.

Add below code in functions.php to insert a custom endpoint.

add_action( 'init', 'custom_endpoint' );
function custom_endpoint() {
  add_rewrite_endpoint( 'custom', EP_ROOT | EP_PAGES );
}

We will add a menu item for this custom endpoint on WooCommerce My Account page menu so that we can access it easily.

add_filter( 'woocommerce_account_menu_items', 'new_menu_items' );
function new_menu_items( $items ) {
  $items[ 'custom' ] = __( 'Custom', 'webkul' );
  return $items;
}

If you want to change the order of my account menu items use the woocommerce_account_menu_items hook.

Now add the content to the custom page with the below code.

$endpoint = 'custom';
add_action( 'woocommerce_account_' . $endpoint .  '_endpoint', 'endpoint_content' );
function endpoint_content() {
    //content goes here
    echo 'This is custom myaccount endpoint.';    
}

Het Patel

I'm a Professional WordPress Developer with 5+ years of web design and development experience including custom websites for small & enterprise businesses. I also have acquired fame and popularity in API Integration & Development and am responsible for producing high-quality solutions for the company customers, Bringing a deep understanding of Modern HTML, JavaScript, and CSS, Plugin Customization, Theme Customization, Theme Creation, creating websites from scratch, and the software development life cycle, And strong ability to execute and implement standard software architecture patterns.

Share
Published by
Het Patel

Recent Posts

Testing hk

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Operation

Testing

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

Create and Used PIPE in angular

In this article, we have to show Create and Used PIPE in angular

2 years ago

TETS NEW

test

3 years ago