0

I am using Woo-Commerce and after activating it a new tab appears with name product I want to change the link of that product tab like if anyone click on that button it will be redirected to the front side add product link instead of Woo-commerce add product page can some one please help me.

Image will eloborate what I am trying to say

1 Answer 1

0

You can modify the admin navigation using the $menu global var. The following will accomplish what you're after

add_action( 'admin_menu', 'my_plugin_edit_admin_menu');
function my_plugin_edit_admin_menu() {
    global $menu, $submenu;
    foreach ($menu as $menuKey => $menuItem)
        if ($menuItem[0] == 'Products')
            $menu[$menuKey][2] = 'https://google.com/'; // wtv link you want

    // UPDATE:
    // remove the sub menu as well (note the GLOBAL var define above)
    $submenu['edit.php?post_type=product'] = ''; 
    unset($submenu['edit.php?post_type=product']);
}
3
  • Thank you so much @David it saved a day can you please tell that how can I hide the submenu as well of this product menu
    – Mohsin
    Dec 9, 2017 at 6:03
  • You may use $submenu to edit the submenu. I've updated the code with it above. Dec 9, 2017 at 19:35
  • Thank you so much it worked and saved most of my time Thank you once again.
    – Mohsin
    Dec 11, 2017 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.