Woocommerce myaccount添加标签不起作用

时间:2016-09-22 18:58:30

标签: php wordpress woocommerce

我想在myaccount页面添加多个标签。我已经在Stackoverflow中搜索了有关此主题的问题,我发现了一些内容,我已经按照他们的说法做了,但是没有从我给出的.php文件中获取内容。

这是代码:



add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );	

function my_custom_my_account_menu_items( $items ) {
    $items = array(
        'dashboard'         		=> __( 'Mein Account', 'woocommerce' ),
        'orders'            		=> __( 'Orders', 'woocommerce' ),
	'meine-trainingsplaene'   	=>     'Meine Trainingspläne', //New Tab!!
	'meine-ernaehrungsplaene' 	=>     'Meine Ernährungspläne', //New Tab!!
        //'downloads'       	  	=> __( 'Downloads', 'woocommerce' ),
	'motivationstipps'   	        =>     'Motivationstipps', //New Tab!!
        //'edit-address'      		=> __( 'Addresses', 'woocommerce' ),
        //'payment-methods'   		=> __( 'Payment Methods', 'woocommerce' ),
        //'edit-account'      		=> __( 'Edit Account', 'woocommerce' ),
        //'customer-logout'   		=> __( 'Logout', 'woocommerce' ),
    );

    return $items;
}

add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );	

add_action( 'init', 'add_wc_endpoint' );
function add_wc_endpoint(){
    add_rewrite_endpoint( 'meine-trainingsplaene', EP_ROOT | EP_PAGES );
	add_rewrite_endpoint( 'meine-ernaehrungsplaene', EP_ROOT | EP_PAGES );
	add_rewrite_endpoint( 'motivationstipps', EP_ROOT | EP_PAGES );
}

add_filter( 'query_vars', 'my_custom_query_vars', 0 );
function my_custom_query_vars( $vars ) {
    $vars[] = 'meine-trainingsplaene';

    return $vars;
}

function my_custom_flush_rewrite_rules() {
    flush_rewrite_rules();
}

add_action( 'wp_loaded', 'my_custom_flush_rewrite_rules' ); //wp_loaded becuase I don't have to reactivate the template (found on Stackoverflow)

function my_custom_endpoint_content() {
    include '../../plugins/woocommerce/templates/myaccount/meine-trainingsplaene.php'; //I've tried it with ../../ to go back from my theme folder to get the new file path plugins/woocommerce etc. but no effekt
}

add_action( 'woocommerce_account_meine-trainingsplaene_endpoint', 'my_custom_endpoint_content' );




0 个答案:

没有答案