Support

Account

Home Forums Gutenberg Get data from block in different page Reply To: Get data from block in different page

  • I wonder if we could use this same approach but instead of 1 block to get the same field from all instances of a given block type, like get_field_block_type( $fieldKey, $blockType );

    It would look over the blocks, but then check for block type and when matching construct an array of the data like:

    function get_field_block_type( $fieldKey, $blockType ) {
      $data = [];
    
      // PARSE BLOCKS
    
      // LOOP OVER BLOCKS...
    
      if( $blockType == $block['type'] ) {
        $data[] = get_field( $fieldKey, $block['id'] );
      }
    
      // END BLOCK LOOP
    
      return $data;
    }