• Hello,
    I’m trying to add a custom attribute to getwid/custom-post-type and getwid/post-carousel using blocks.registerBlockType:

    const blocksWithSubpageLink = [ 'getwid/custom-post-type', 'getwid/post-carousel' ];
    
    function formatsSubpageAttribute(settings, name) {
      if (typeof settings.attributes !== 'undefined') {
        if ( blocksWithSubpageLink.includes( name ) || hasBlockSupport( name, 'formatsSubpage' ) ) {
          settings.attributes = Object.assign(settings.attributes, {
            showSubpageLink: {
              type: 'boolean',
              default: false
            }
          });
          // console.log(settings.attributes)
        }
      }
      return settings;
    }
    
    addFilter(
      'blocks.registerBlockType',
      's24/brand-formats-subpage',
      formatsSubpageAttribute
    );

    If that attribute has a value (even the default one) the block rendering fails.
    Console error:
    Failed to load resource: the server responded with a status of 400 (Bad Request)

    It seems that custom attribute are forbidden, perhaps for some data validation.

    Do you have any suggestions or ideas?
    Thanh you!

  • The topic ‘custom-post-type and post-carousel custom attributes’ is closed to new replies.