我正在成功地添加一个新的自定义选项卡到WooCommerce我的帐户部分.但我无法更改菜单项链接,它仍然绑定到‘My-Account’URL.
I want to remove the http://site-test.local/my-account
from this absolute link "http://site-test.local/my-account/https:/mycustomwebsite.com/"
我只是想有"https:/mycustomwebsite.com/"当我点击"新自定义选项卡"菜单链接.
以下是我添加到主题函数.php文件中的代码:
function custom_add_my_account_menu_item($items) {
// Add a new menu item with the key 'custom_option'
$items['https://mycustomwebsite.com'] = __('NEW CUSTOM TAB', 'your-text-domain');
$cleanLink = str_replace('http://site-test.local/my-account', '', $items); //I'm trying to remove the site-test.local/my-account, but it doesn't work
$items = $cleanLink;
return $items;
}
add_filter('woocommerce_account_menu_items', 'custom_add_my_account_menu_item');
// Display content for the custom option in the My Account section
function custom_my_account_endpoint_content() {
echo '<p>This is the content for the custom option.</p>';
}
add_action('woocommerce_account_custom_option_endpoint', 'custom_my_account_endpoint_content');
如何将菜单项链接更改为自定义链接?