• Hi all,

    I created a custom post type for a custom theme and all is functioning great. Except for on e thing. I added al the native support for the custom post type, like author, excerpt, etc.

    The thing is, all these options are shown when editing an post in this custom post type. I tried several hooks to hide (not remove) the meta boxes but none are working. For example:

    /**
    * vpm_default_hidden_meta_boxes
    */
    function vpm_default_hidden_meta_boxes( $hidden, $screen ) {
    // Grab the current post type
    $post_type = $screen->post_type;

    // If we’re on a ‘post’…
    if ( $post_type == ‘dives’ ) {
    // Define which meta boxes we wish to hide
    $hidden = array(
    ‘authordiv’,
    ‘revisionsdiv’,
    );

    // Pass our new defaults onto WordPress
    return $hidden;
    }

    // If we are not on a ‘post’, pass the
    // original defaults, as defined by WordPress
    return $hidden;
    }

    add_action( ‘default_hidden_meta_boxes’, ‘vpm_default_hidden_meta_boxes’, 10, 2 );

    This snippet should hide by default the author and revisions meta box for the post type “dives”, which is my custom post type. It isn’t working however.

    Am I doing something wrong here? Or do you know an alternative to get this working?

    Thanks!
    Justin

Viewing 1 replies (of 1 total)
  • Thread Starter jjanson

    (@jjanson)

    Hi all,

    Nevermind, got it the script above working. I didn’t place the code in the themes functions.php but in an other attached script for metaboxes. Pasting it in functions.php did the trick.

    Justin

Viewing 1 replies (of 1 total)
  • The topic ‘Hiding meta boxes in custom post types’ is closed to new replies.