Adding a Gutenberg-like custom field on a custom post type

I’ve googled this a bunch, there’s a couple of answers for old versions (pre-gutenberg) of WordPress but none that I could find for Gutenberg.

Essentially I have a custom post type I added by editing my functions.php like so:


        // Our custom post type function
        function create_posttype() {

            register_post_type( 'Featured Sites',
            // CPT Options
                array(
                    'labels' => array(
                        'name' => __( 'Featured site' ),
                        'singular_name' => __( 'Featured sites' )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => 'featured-sites'),
                    'show_in_rest' => true,
                )
            );
        }
        // Hooking up our function to theme setup
        add_action( 'init', 'create_posttype' );

That’s all working fine and dandy, but at the moment adding new content through it looks just like adding a post or a page.

Is there any way to connect custom input fields with Gutenberg blocks?

For example, could I have a block sitting on top of my post title that allows me to select certain colors, or select a specific value from a dropdown?

Something like adding a supports value:

 'supports' => array( 'my-custom-input' ),

Custom fields do essentially what I want, I’d just like a more visual way to associate values with my custom fields.

Edit:
This plugin seems to do what I want, however I can’t seem to get it working with my Custom Post Type. Unsure if I’m missing something, the documentation doesn’t mention it.

0

Leave a Comment