Support » Plugin: Gutenberg » allowed_block_types not working for custom Gutenberg blocks on Custom Post Types

  • Attempting to use custom Gutenberg blocks on a Custom Post Type. CPT has show_in_rest set to true, and all core Gutenberg blocks work. But no custom Gutenberg blocks show (they all show appropriately on default Pages and Posts)

    The allowed_block_types filter was originally set to a boolean of 1, so all blocks should be allowed. But Custom blocks still weren’t showing. Tried overriding with the below code, but only the paragraph shows (or other core blocks that I add) – never the custom blocks.

    
    public function allowed_block_types( $allowed_block_types, $post ) {
    	$allowed_block_types = [
    	    'core/paragraph',
    	    'custom/text-cta',
    	    'custom/text-cta-item'
    	];
    
    	return $allowed_block_types;
    }
    add_filter( 'allowed_block_types', [ $this, 'allowed_block_types' ], 10, 2 );
    

    What am I missing?!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘allowed_block_types not working for custom Gutenberg blocks on Custom Post Types’ is closed to new replies.