如何在 WooCommerce 中显示每个自定义选项卡的内容

问题描述 投票:0回答:0

使用下面的代码,我向 WooCommerce 添加了多个选项卡,我的帐户选项卡带有端点,唯一的问题是:我无法为每个端点显示选项卡的自定义内容,请问还有吗?

function pa_custom_endpoint_keys() {
    global $wpdb;
    $charset_collate = $wpdb->get_charset_collate();
    $pao  = $wpdb->prefix . 'pao';
    $results=$wpdb->get_results("select * from $pao");
        $endpointsdata =array();
        foreach($results as $row){
        $endpointsdata[$row->pao_name] = $row->pao_value;
        }
        return $endpointsdata;
}
add_action( 'init', 'pa_custom_endpoint' );
function pa_custom_endpoint() {
    foreach(pa_custom_endpoint_keys() as $endpointkey=>$endpointlable){
    add_rewrite_endpoint( $endpointkey, EP_ROOT | EP_PAGES );
    }
}
add_filter( 'query_vars', 'pa_custom_endpoint_query_vars', 0 );
function pa_custom_endpoint_query_vars( $vars ) {
    foreach(pa_custom_endpoint_keys() as $endpointkey=>$endpointlable){
    $vars[] = $endpointkey;
    }
    return $vars;
}
add_filter( 'woocommerce_account_menu_items', 'pa_custom_endpoint_link_my_account' );
function pa_custom_endpoint_link_my_account( $items ) {
    foreach(pa_custom_endpoint_keys() as $endpointkey=>$endpointlable){
    $items[$endpointkey] = $endpointlable;
    }
    return $items;
}
        function mine(){//i just need to make this function like this $mine(){}
                   echo do_shortcode( ' /* your shortcode here  ' );
        }
                    foreach(pa_custom_endpoint_keys() as $endpointkey=>$endpointlable){
                
                    add_action( 'woocommerce_account_' . $endpointkey . '_endpoint', 'mine' );
            }

wordpress woocommerce endpoint
© www.soinside.com 2019 - 2024. All rights reserved.