Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Step one- you need to create a page and grab its page id
- //Step two - paste the set of functions in your functions.php file
- //Step - In this example Vidoe is the page and it's the end point
- // create a custom end point in the My Accunt Page
- function custom_wc_end_point() {
- if(class_exists('WooCommerce')){
- add_rewrite_endpoint('videos', EP_ROOT | EP_PAGES );
- add_rewrite_endpoint('new_one', EP_ROOT | EP_PAGES );
- }
- }
- add_action( 'init', 'custom_wc_end_point' );
- function custom_endpoint_query_vars( $vars ) {
- $vars[] = 'videos';
- $vars[] = 'new_one';
- return $vars;
- }
- add_filter( 'query_vars', 'custom_endpoint_query_vars', 0 );
- function ac_custom_flush_rewrite_rules() {
- flush_rewrite_rules();
- }
- add_action( 'after_switch_theme', 'ac_custom_flush_rewrite_rules' );
- // add the custom endpoint in the my account nav items
- function custom_endpoint_acct_menu_item( $items ) {
- $logout = $items['customer-logout'];
- unset( $items['customer-logout'] );
- $items['videos'] = __( 'Videos', 'woocommerce' ); // replace videos with your endpoint name
- $items['new_one'] = __( 'New One', 'woocommerce' ); // replace videos with your endpoint name
- $items['customer-logout'] = $logout;
- return $items;
- }
- add_filter( 'woocommerce_account_menu_items', 'custom_endpoint_acct_menu_item' );
- // fetch content from your source page (in this case video page)
- function fetch_content_custom_endpoint() {
- global $post;
- $id = "987452884"; // your video page id
- ob_start();
- $output = apply_filters('the_content', get_post_field('post_content', $id));
- $output .= ob_get_contents();
- ob_end_clean();
- echo $output;
- }
- add_action( 'woocommerce_account_videos_endpoint', 'fetch_content_custom_endpoint' );
- function fetch_content_custom_endpoint_two() {
- global $post;
- $id = "987452490"; // your new one page id
- ob_start();
- $output = apply_filters('the_content', get_post_field('post_content', $id));
- $output .= ob_get_contents();
- ob_end_clean();
- echo $output;
- }
- add_action( 'woocommerce_account_new_one_endpoint', 'fetch_content_custom_endpoint_two' );
Add Comment
Please, Sign In to add comment