How to get a field value of custom block? I have a custom block type, called "Features block". I added a field as alternative title (field_block_alt_title is that machine name).

I would like to display this alternative title on frontpage programmatically.

Now, I have this code so far that is displaying the title of blocks:

&lt;?php

use Drupal\Component\Utility\Html;
use Drupal\Core\Render\Element;

function neft_preprocess_region(&amp;$variables) {
  if ($variables['region'] == 'flick') {
    $titles = array();
    $ids = array();
    $block_ids = Element::children($variables['elements']);
    foreach ($block_ids as $block_id) {
      $block_title = Drupal\block\Entity\Block::load($block_id)-&gt;label();
      $titles[] =  Html::escape($block_title);
      $ids[] = 'block-' . Html::getUniqueId($block_id);
    }
    if (count($titles) &amp;&amp; count($ids)) {
      $tabs = '&lt;ul&gt;';
      foreach ($titles as $key =&gt; $title) {
        $tabs .= "&lt;li&gt;&lt;a href=\"#$ids[$key]\"&gt;$title&lt;/a&gt;&lt;/li&gt;";
      }
      $tabs .= '&lt;/ul&gt;';
      $variables['tabs'] = $tabs;
    }
  }
}
Fields of custom blocks are in block content. So you have to load the block content first, before you can get the field value:

$block = \Drupal\block\Entity\Block::load($block_id);
$uuid = $block-&gt;getPlugin()-&gt;getDerivativeId();
$block_content = \Drupal::service('entity.repository')-&gt;loadEntityByUuid('block_content', $uuid);
if ($block_content) {
  $field_value = $block_content-&gt;field_block_alt_title-&gt;value;
}