Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to remove the gallery metabox which is added by WooCommerce - its been added in an update, but I already have a Gallery metabox, and I don't want to confuse the client.

Obviously I can hack the plugin, but I'd like to do it from the functions.php

I've tried:

function remove_my_meta_boxes() {
    remove_meta_box( 'woocommerce-product-images',  'product', 'side');
add_action( 'admin_menu' , 'remove_my_meta_boxes', 40 );

It doesn't seem to work

The code that's adding it seems to be

public function __construct() {
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 );


public function add_meta_boxes() {
    add_meta_box( 'woocommerce-product-images', __( 'Product Gallery', 'woocommerce' ), 'WC_Meta_Box_Product_Images::output', 'product', 'side' );

I've removed sections which aren't relevant - ie other metaboxes registered etc.

share|improve this question

closed as off-topic by Howdy_McGee, mrwweb, Mayeenul Islam, Robert hue, TheDeadMedic Apr 9 at 11:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

You could give this plugin a try. – tfrommen Feb 19 '14 at 19:58

2 Answers 2

up vote 4 down vote accepted

A quick search in their GitHub repo shows the following line:

    __( 'Product Gallery', 'woocommerce' ),

So your call to remove_meta_box() uses the right id/handle/name as well as the right priority and context.

The problem just is the hook and the priority at which the hook executes - you have to unregister later than the WooCommerce plugin registers the boxes. Else you try to deregister something that isn't yet registered.

add_action( 'add_meta_boxes' , 'remove_my_meta_boxes', 40 );
function remove_my_meta_boxes()
    remove_meta_box( 'woocommerce-product-images',  'product', 'side');
share|improve this answer
great! Thanks! I can't really say I understand it though. Why does the 'add_meta_boxes' make the difference? This is all pretty new to me I'm afraid. – JorgeLuisBorges Feb 19 '14 at 20:13
@JorgeLuisBorges That's the hook WooThemes guys use to register the box. admin_menu is another hook that runs much earlier, so you're trying to remove something that isn't even registered at that point. 40 is the priority for the callback/action as Woo uses 30 and lower. – kaiser Feb 19 '14 at 20:16

It should be possible to remove that metabox but you will have to remove it after it has been added. I think you are trying to do that with the priority argument but you are also using a different hook and one which, if memory server, runs before the hook being used by the plugin.

function remove_my_meta_boxes() {
    remove_meta_box( 'woocommerce-product-images',  'product', 'side');
add_action( 'add_meta_boxes' , 'remove_my_meta_boxes', 40 );
share|improve this answer

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