Programmatically accessing block content Could anyone tell me how to programmatically access the field content of a custom block?

Thus far I've managed:

use Drupal\block\Entity\Block;
$block = Block::load($block_name);

if ($block) {
  $render = \Drupal::entityTypeManager()
    -&gt;getViewBuilder('block')
    -&gt;view($block);
}


However this doesn't give me access to the fields and their data.
Your code loads a configured block, not the content of a custom block.

This will load the field data of block content:

$custom_block = \Drupal::entityTypeManager()-&gt;getStorage('block_content')-&gt;load('1');
$fieldcontent = $custom_block-&gt;field_myfield-&gt;value;