Skip to content

Instantly share code, notes, and snippets.

@nickmeagher
Created January 12, 2018 21:42
Show Gist options
  • Save nickmeagher/6576611103c50c8e3725a1693e717dcc to your computer and use it in GitHub Desktop.
Save nickmeagher/6576611103c50c8e3725a1693e717dcc to your computer and use it in GitHub Desktop.
Add Wishlist to "My Account" Page
<?php
/*
* Register new wishlist endpoint
*/
function primer_add_wishlist_endpoint() {
add_rewrite_endpoint( 'wish-list', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'primer_add_wishlist_endpoint' );
/*
* Register new wishlist endpoint
*/
function primer_wishlist_query_vars( $vars ) {
$vars[] = 'wish-list';
return $vars;
}
add_filter( 'query_vars', 'primer_wishlist_query_vars', 0 );
/*
* Change the order of the endpoints that appear in My Account Page - WooCommerce 2.6
*/
function wpb_woo_my_account_order() {
$myorder = array(
'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Past Orders', 'woocommerce' ),
'wish-list' => __( 'Wishlist', 'woocommerce' ),
'edit-address' => __( 'Addresses', 'woocommerce' ),
'edit-account' => __( 'Account Details', 'woocommerce' ),
'customer-logout' => __( 'Logout', 'woocommerce' ),
);
return $myorder;
}
add_filter ( 'woocommerce_account_menu_items', 'wpb_woo_my_account_order' );
/*
* Add Wishlist Shortcode - https://wordpress.org/plugins/ti-woocommerce-wishlist/
*/
function woocommerce_wishlist_content() {
echo do_shortcode( '[ti_wishlistsview]' );
}
add_action( 'woocommerce_account_wish-list_endpoint', 'woocommerce_wishlist_content' );
?>
@arivers-coding
Copy link

Thanks @nickmeagher, nice & to the point. While it seems to be working I have come across an issue. If you remove an item or add an item to cart the My Account Sidebar does not remain and the Wishlist takes up a whole page. Would there be a way to force the My Account Sidebar stay put?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment