Find us on Facebook

LightBlog
Responsive Ads Here

Thứ Sáu, 29 tháng 12, 2017

How to change the link of product menu from wordpress admin panel

Question:

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

Answer:

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

Không có nhận xét nào:

Đăng nhận xét