2

We have tried to change the products page at the back end title menu but we couldn't using the snippet below in the screenshot:

enter image description here

We need to change both the menu title "Products" to " New Title " & Sumbmenu "All Products" to " All Submenu "

add_filter( 'gettext', 'custom_translate_woocommerce_strings', 999, 3 );

function custom_translate_woocommerce_strings( $translated, $text, $domain ) {

    $translated = str_ireplace( 'Product', 'New Title', $translated );

    return $translated;
}
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
Maged Mohamed
  • 511
  • 5
  • 27

1 Answers1

5

The first part of the code is to debug, this will show you the menu in detail on the dashboard. (you can remove this afterwards)

The 2nd part in this example adds the changes

enter image description here

It is therefore a matter of adjusting based on the detail

// DEBUG: This displays the complete wordpress admin menu on your dashboard for admin only.
function debug_admin_menus() {
    global $menu, $submenu, $pagenow;
    if ( current_user_can('manage_options') ) {
        if( $pagenow == 'index.php' ) {  // print on dashboard
            echo '<pre>', print_r( $menu, 1 ), '</pre>'; // top level menus
            echo '<pre>', print_r( $submenu, 1 ), '</pre>'; // submenus
        }
    }
}
add_action( 'admin_notices', 'debug_admin_menus' );

// Change label
function custom_change_admin_label() {
    global $menu, $submenu;

    $menu[26][0] = 'New Title';
    $submenu['edit.php?post_type=product'][5][0] = 'All Submenu';
}
add_action( 'admin_menu', 'custom_change_admin_label' );
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
  • Worked great, thank you sir .. can we have your contact info for freelancing work ? – Maged Mohamed Apr 08 '20 at 21:10
  • @MagedMohamed An advice: For free lance contacts, you can choose some people [from the top user list for WooCommerce Tagged questions](https://stackoverflow.com/tags/woocommerce/topusers), going through their profiles to get their contact information. – LoicTheAztec Apr 09 '20 at 08:33
  • @LoicTheAztec we just though that top guys are expensive, but how can we contact you sir ?, email ? – Maged Mohamed Apr 09 '20 at 10:40