Created
January 12, 2018 21:42
-
-
Save nickmeagher/6576611103c50c8e3725a1693e717dcc to your computer and use it in GitHub Desktop.
Add Wishlist to "My Account" Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); | |
?> |
NEXT PAGE BUTTON won't work, it's missing the rules for pagination.
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
Thank you for the code! I have the same issue like in the thread: https://wordpress.org/support/topic/add-wishlist-to-my-account-page/ I have added everything between the php tag into the functions.php of my (child) theme.
The account-sidebar isn´t displayed on the wishlist page. I have tried your code and the code from the thread. I have changed my wishlist-page to a subpage from "my account" and changed the code to the german name of my whishlist ("wunschliste"). That removes the 404 error but doesn´t solve the problem.
Does anyone has an idea?
Thanks in advance!