i added a custom endpoint to myaccount menu and it corrispond to the Yith Woccommerce Wishlist. I added this code in order to create the edpoint and show the content:
function my_custom_endpoints() {
add_rewrite_endpoint( 'yith-my-wishlist', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
function my_custom_query_vars( $vars ) {
$vars[] = 'yith-my-wishlist';
return $vars;
}
add_filter( 'query_vars', 'my_custom_query_vars', 0 );
function my_flush_rewrite_rules() {
flush_rewrite_rules();
}
add_action( 'wp_loaded', 'my_flush_rewrite_rules' );
function my_custom_my_account_menu_items( $items ) {
$items = array(
'customer-logout' => __( 'Logout', 'woocommerce' ),
'edit-account' => __( 'My Profile', 'woocommerce' ),
'yith-my-wishlist' => __('My Wishlist', 'woocommerce'),
//'dashboard' => __( 'Dashboard', 'woocommerce' ),
'orders' => __( 'Orders', 'woocommerce' )
//'downloads' => __( 'Downloads', 'woocommerce' ),
//'edit-address' => __( 'Addresses', 'woocommerce' ),
//'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
);
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
function my_custom_endpoint_content() {
include 'yith-woocommerce-wishlist/wishlist-view.php';
}
add_action( 'woocommerce_account_special-page_endpoint', 'my_custom_endpoint_content' );
But the content doesn't appear. I think I got wrong on the url in the my_custom_endpoint_content() function.
I have a child theme and this code is in the functions.php of the child theme. I copied the folder of the yith plugin in the childtheme folder with the file i want to show.
How can i fix it ?
your
should have been
it is in this format
'woocommerce_account_' . $key . '_endpoint'where the$keyin your case isyith-my-wishlist.Also, I think
include 'yith-woocommerce-wishlist/wishlist-view.php';will not work on the functions.php. You need the path to the plugin if this file is from a plugin.