Skip to main content
Category:

Code snippet that can be used to load nodes to print the node fields in drupal 8.

$nids = \Drupal::entityQuery('node')
  ->condition('type', $content_type, '=')
  ->condition('status', 1, '=')
  ->execute();

$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nids);

foreach ($nodes as $key => $value) {
  $title =  $value->title->value;
  $description =  $value->body->value;
}

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook