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.'; }