>  Q&A  >  본문

WooCommerce 사용자 정의 탭 콘텐츠 표시 문제를 해결하는 방법

아래 코드를 사용하여 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' );
            }

P粉986937457P粉986937457381일 전460

모든 응답(1)나는 대답할 것이다

  • P粉026665919

    P粉0266659192023-09-07 16:02:04

    으아악

    회신하다
    0
  • 취소회신하다