簡體   English   中英

Woocommerce自定義端點內容網址

[英]Woocommerce custom Endpoint content url

我在myaccount菜單中添加了一個自定義端點,它與Yith Woccommerce心願單相對應。 我添加了以下代碼以創建編輯點並顯示內容:

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' );

但是內容沒有出現。 我認為my_custom_endpoint_content()函數中的網址有誤。

我有一個子主題,此代碼位於子主題的functions.php中。 我用要顯示的文件將yith插件的文件夾復制到childtheme文件夾中。

我該如何解決?

你的

add_action( 'woocommerce_account_special-page_endpoint', 'my_custom_endpoint_content' );

本來應該

add_action( 'woocommerce_account_yith-my-wishlist_endpoint', 'my_custom_endpoint_content' );

格式為'woocommerce_account_' . $key . '_endpoint' 'woocommerce_account_' . $key . '_endpoint' 'woocommerce_account_' . $key . '_endpoint'在您的情況下$keyyith-my-wishlist

另外,我認為其中include 'yith-woocommerce-wishlist/wishlist-view.php'; 將無法在functions.php上工作。 如果此文件來自插件,則需要插件的路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM