AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
835 stars 171 forks source link

Ability to adjust remove_wp_meta_box per post type #836

Open paulschreiber opened 1 year ago

paulschreiber commented 1 year ago

By default, ACF hides the custom posts metabox. You can reenable it like so:

add_filter( 'acf/settings/remove_wp_meta_box', '__return_false' );

However, this turns it on or off for all post and all post types. If you attempt to enable it for a specific post type:

add_action( 'wp', function() {
    if ( 'sample-cpt' === get_post_type() ) {
        // Show custom fields boxes, even when ACF is installed
        add_filter( 'acf/settings/remove_wp_meta_box', '__return_false' );
    }
});

This will fail as the wp hook happens after ACF has already initialized.

It would be helpful if you allowed the custom posts metabox to be enabled/disable at a later point in the action-firing sequence.