简体   繁体   English

如何在woocommerce我的帐户页面中对自定义选项卡重新排序?

[英]How to reorder custom tab in woocommerce my account page?

I created a custom tab (My Favorites) for my Woocommerce my account page and placed the below code in my child theme's functions.php file. 我为Woocommerce我的帐户页面创建了一个自定义选项卡(我的收藏夹),并将以下代码放在子主题的functions.php文件中。 When I did that, the custom tab is ordered at the bottom of the rest of the tabs. 当我这样做时,自定义选项卡将在其余选项卡的底部排序。

So I was wondering, is a way to reorder it further up the list of tabs? 所以我想知道,是否可以在选项卡列表中重新排序?

Specifically I would like to reorder my custom tab (My Favorites) above the "Account Details" tab. 具体来说,我想对“帐户详细信息”标签上方的自定义标签(“我的收藏夹”)重新排序。

image link 图片链接

function add_myfavorites_endpoint() {
    add_rewrite_endpoint( 'myfavorites', EP_ROOT | EP_PAGES );
}

add_action( 'init', 'add_myfavorites_endpoint' );


function myfavorites_query_vars( $vars ) {
    $vars[] = 'myfavorites';
    return $vars;
}

add_filter( 'query_vars', 'myfavorites_query_vars', 0 );


function add_myfavorites_link_my_account( $items ) {
    $items['myfavorites'] = 'My Favorites';
    return $items;
}

add_filter( 'woocommerce_account_menu_items', 'add_myfavorites_link_my_account' );


function myfavorites_content() {
echo '<h3>My Favorites</h3><p>';
echo do_shortcode( ' [my_content_shortcode] ' );
}

add_action( 'woocommerce_account_myfavorites_endpoint', 'myfavorites_content' );
// Rename, re-order my account menu items
function fwuk_reorder_my_account_menu() {
    $neworder = array(
        'dashboard'          => __( 'Dashboard', 'woocommerce' ),
        'orders'             => __( 'Previous Orders', 'woocommerce' ),
        'wishlist-link'      => __( 'Wishlist', 'woocommerce' ),
        'edit-address'       => __( 'Addresses', 'woocommerce' ),
        'edit-account'       => __( 'Account Details', 'woocommerce' ),
        'customer-logout'    => __( 'Logout', 'woocommerce' ),
    );
    return $neworder;
}
add_filter ( 'woocommerce_account_menu_items', 'fwuk_reorder_my_account_menu' );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有条件地在woocommerce我的帐户页面上显示一个标签 - Display a Tab on the woocommerce my account page conditionally Woocommerce 如何在我的帐户页面上重定向自定义端点 - Woocommerce how to redirect a custom end point on my-account page 重新排列Woocommerce我的帐户部分中的菜单项 - Reorder menu items in Woocommerce My Account section 从自定义 WooCommerce 我的帐户选项卡保存表单数据 - Saving form data from a custom WooCommerce My Account tab 从“我的帐户”自定义选项卡提交 woocommerce 订单跟踪表 - Submit woocommerce order tracking form from My Account custom tab WooCommerce:覆盖我帐户页面中“浏览器”选项卡上设置的标题 - WooCommerce: Override the title set to the browsers tab in my account page 如何更改 WooCommerce 我的帐户页面标题? - How to change WooCommerce My Account page titles? WooCommerce 我的帐户页面自定义菜单项与自定义链接 - WooCommerce My Account page custom menu item with custom link Woocommerce 我的帐户自定义页面 - 找不到页面 404(永久链接问题) - Woocommerce my account custom page - page not found 404 (permalinks problem) Woocommerce:验证我的帐户编辑页面上的自定义字段 - Woocommerce: validate custom fields on my account edit page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM