Metabox apply only to custom post

Support General Metabox apply only to custom post

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33237
    Hernan OrellanaHernan Orellana
    Participant

    I created a custom post type so that I could create a custom visual presentation for data entry. I tried using the Metabox online builder to create a backend GUI. How do I get the backend data entry GUI to appear ONLY on the custom Post type that I created? Right now it appears on all posts.

    #33244
    Long NguyenLong Nguyen
    Moderator

    Hi Hernan,

    You need to define the post_types setting when registering the meta box. For example:

    add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
    function prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = [
            'title'      => 'Personal Information',
            'post_types' => 'post-type-slug', //here
            'id' => 'my-meta-box',
            'fields' => [
                ...
            ]
        ];
        return $meta_boxes;
    }

    Read more on the documentation https://docs.metabox.io/creating-meta-boxes/#field-group-settings

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.