Support » Fixing WordPress » default_hidden_meta_boxes not firing?

  • Hi,

    I want to hide slug metabox and author metabox in my post edit page. I tried to use the hook default_hidden_meta_boxes for this, but it seems like the hook does not fire my callback function. I cannot find strings 'Hook for hiding meta boxs' in my debug log at all. Is this hook no longer usable?

    add_filter('default_hidden_meta_boxes','hide_meta_box', 10, 2);
    function hide_meta_box($hidden, $screen) {
          $hidden = array('slugdiv','authordiv');
            error_log('Hook for hiding meta boxs');
        return $hidden;
Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Is this hook no longer usable?

    It isn’t that it is not usable, it’s that those metaboxes no longer exist. Metaboxes themselves no longer exist, and have not since 5.0, when the new block editor came out.

    If you are using the Classic Editor, then you can see that this hook still works because on the old Classic Editor screen. the “Screen Options” dropdown in the upper right still exists, and those checkboxes there will let you turn the various metaboxes in the classic editor off and on and such.

    But the new Block Editor has no such metaboxes. Metaboxes are not used anymore. They’re not in the editing screens anywhere. The whole “metabox” layout is all pre-2018, basically. No new screens should be made using it, it should be phased out completely over time.

    Thread Starter kghugo2000


    I see. I have a CPT that only supports ‘author’, are the metabox ‘author’ and ‘slug’ there belongs to the Block editor despite its appearance?

    If so, what hook should I use to hide them?


    Thank you so much for your help.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    No, that is the old style, and those are indeed metaboxes, and the default_hidden_meta_boxes filter will be called there.

    But it only changes the defaults, not the individual choices you make as of what to see or not to see. The default_hidden_meta_boxes hook will not get called if the user has made any types of choices about what metaboxes they want to be displayed. See the call to get_user_option( "metaboxhidden_{$screen->id}" ); on line 157 of /wp-admin/includes/screen.php.

    Thread Starter kghugo2000


    I see. If I use remove_meta_box() to remove ‘slug’ and ‘author’ metabox, would data for ‘slug’ and ‘author’ not saved into the database properly?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘default_hidden_meta_boxes not firing?’ is closed to new replies.