• Resolved JacoboPolavieja

    (@jacobopolavieja)


    Hello all,

    I’m trying to remove the “normal” meta box that gets added after registering a new custom taxonomy. I’m calling the function like this:
    remove_meta_box('tagsdiv-main_country','post','core');

    And all I’m getting when I try to access the admin panel is:
    Fatal error: Call to undefined function remove_meta_box() in /home4/thehoops/public_html/thm1/wp-content/themes/the-hoops-market/functions.php on line 82

    I’ve look at the div I want to remove through bugzilla and the ID is good. Besides, the error talks about an “undefined” function, not a bad parameter on the function or something like that.

    Any idea what may be happening? Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You are most likely calling the function before it is defined. In a recent project, I found that this function is sage to use during the admin_head action. Try something like this:

    add_action( 'admin_head', 'remove_my_meta_boxen' );
    function remove_my_meta_boxen() {
    	remove_meta_box('tagsdiv-main_country','post','core');
    }
    Thread Starter JacoboPolavieja

    (@jacobopolavieja)

    Thanks for helping Michael!

    Unfortunately, this doesn’t output any errors but doesn’t remove the box either. I suppose the solution must be something along those lines of including something or executing it some way, in order to have the remove_meta_box function defined, but can’t find how to correctly do it.

    Thanks anyway and if I find any solution I’ll write back. Cheers!

    I just looked over some code that removes taxonomy meta boxen and fortunately there is a difference from what is posted above. Try using ‘side’ as the third parameter instead of ‘core’:

    remove_meta_box( 'tagsdiv-main_country','post','side' );

    Thread Starter JacoboPolavieja

    (@jacobopolavieja)

    That did the trick!

    Many many thanks Michael. These tiny things take more time to fix than one might thing at first. Another step closer… so thank you a lot for taking the time to look at it.

    Just for curiosity, where did you find that code? Maybe there’s something more I can learn ;).

    Thanks! Cheers!

    No problem, Glad I could help. The code was from an abandoned module for a project that I am working on. Not sure it would be of any benefit to be honest.

    azureardee

    (@azureardee)

    Thank you for this! I had the same problem, and putting remove_meta_box in admin_head did the trick. Thanks again!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fatal error: Call to undefined function remove_meta_box()’ is closed to new replies.