0

I've been trying to follow a couple of methods for moving the WooCommerce Products and WooCommerce menu entries to the top of the Dashboard, but so far I've had no success. I've tried the following:

function menu_order( $menu_order ) {
    if ( ! $menu_order ) {
        return true;
    }

    error_log( print_r( $menu_order, true ) );

    return array(
        // Shop
        'post.php?post=' . get_option( 'woocommerce_shop_page_id' ) . '&action=edit',
        'edit.php?post_type=products',
        'edit.php?post_type=page',
        'separator1',
        // Settings.
        'nav-menus.php',
        'upload.php',
        // Admin options.
        'separator-last',
        'themes.php',
        'plugins.php',
        'users.php',
        'tools.php',
        'options-general.php',
    );
}

add_filter( 'custom_menu_order', '__return_true', 10 );
add_filter( 'menu_order', 'Namespace\menu_order', 99, 1 );

That error_log() prints out an array of the menu entries that doesn't include either of the registered WooCommerce settings pages.

I've also tried removing the menus and readding them with a different priority (default was 55.5, I tried 0-10). I was successful at moving the WooCommerce menu up slightly, but not to the top, as I'd wanted.

I've tried looking at the class that adds this menu, but it doesn't seem like it's doing anything out of the ordinary to add the menu (basically done the way I do it above, except searching the array for the keys and rearranging just those two. The priority for menu_order here is also lower than my 99 priority above.

Edit to mention that my filter above does hide posts and moves pages to the top, so I know that it's working at least in that respect.

1

Try changing your line 'edit.php?post_type=products', to 'edit.php?post_type=product', instead.

Simple but it worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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