Skip to content

Instantly share code, notes, and snippets.

@dustinleer
Created May 25, 2022 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinleer/24bcd8faedb4ec7eb01ad0391bee759d to your computer and use it in GitHub Desktop.
Save dustinleer/24bcd8faedb4ec7eb01ad0391bee759d to your computer and use it in GitHub Desktop.
Add a custom WooCommerce My Account endpoint
<?php
/**
* Add endpoint rewrite.
*/
function ip_custom_endpoint() {
add_rewrite_endpoint( 'edit-wishlists', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'ip_custom_endpoint', 10, 1 );
/**
* Insert the new endpoint into the My Account menu.
*
* @param array $items
* @return array
*/
function ip_new_menu_items( $items ) {
$items[ 'edit-wishlists' ] = __( 'Wishlists', 'ip_master' );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'ip_new_menu_items', 10, 1 );
$endpoint = 'edit-wishlists';
/**
* Insert the new endpoint content into the My Account area.
*/
function ip_endpoint_content() {
echo '<div id="wl-wrapper" class="woocommerce">';
echo '<h2>Wishlists</h2>';
echo get_template_part( 'wishlist-manage' );
echo '</div>';
}
add_action( 'woocommerce_account_' . $endpoint . '_endpoint', 'ip_endpoint_content', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment