use Drupal\node\Entity\NodeType;
/**
* Page preprocess function for get oher Content Type
*/
function themename_preprocess_page(&$variables) {
$all_content_types = NodeType::loadMultiple();
/** @var NodeType $content_type */
foreach ($all_content_types as $machine_name) {
$ct_name = 'direction';
if ($machine_name == $ct_name) {
$entities = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => $machine_name]);
$variables['direction'] = $entities;
}
}
}
<ul>
{% for item in direction %}
{% set title = item.title.value %}
{% set parts = item.field_direction_part %}
<li>
{{ title }}
<ul>
{% for part in parts %}
{% set title = part.entity.title.value %}
<li>{{ title }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>