Php Woocommerce自定义端点内容url

Php Woocommerce自定义端点内容url,php,woocommerce,endpoints,Php,Woocommerce,Endpoints,我在myaccount菜单中添加了一个自定义端点,它将响应Yith Woccommerce愿望列表。 我添加此代码是为了创建edpoint并显示内容: function my_custom_endpoints() { add_rewrite_endpoint( 'yith-my-wishlist', EP_ROOT | EP_PAGES ); } add_action( 'init', 'my_custom_endpoints' ); function my_custom_query_var

我在myaccount菜单中添加了一个自定义端点,它将响应Yith Woccommerce愿望列表。 我添加此代码是为了创建edpoint并显示内容:

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()函数中的url错误了

我有一个子主题,这段代码在子主题的functions.php中。我在childtheme文件夹中复制了yith插件的文件夹以及我想要显示的文件

我怎样才能修好它?

你的

add_action( 'woocommerce_account_special-page_endpoint', 'my_custom_endpoint_content' );
应该是

add_action( 'woocommerce_account_yith-my-wishlist_endpoint', 'my_custom_endpoint_content' );
它的格式是“woocommerce\u account”$钥匙。”_端点“,其中您案例中的
$key
yith my wishlist


另外,我认为
应该包括'yith-woocommerce-wishlist/wishlist-view.php'
在functions.php上不起作用。如果此文件来自某个插件,则需要该插件的路径。

您的意思是来自wp内容/插件?如果我要自定义这个文件,我不需要得到子主题路径吗?wishlist view.php在哪里?啊,它是一个错误的类型。我还将路径更改为绝对路径,但我不喜欢此路径。我把/home/[site\u name]/public\u html/wp content。。。。它安全吗?wishlist-view.php在wp-content/plugins/yith-woocommerce-wishlist中,我也在child\u-theme/yith-woccommerce-wishlist中复制了它。查看yith插件的init文件。。可能有类似于
define('YITH_uuupath',plugin_udir_upath(uu文件_uuu))
的内容,您可以使用该变量。