Here im loading nodes by "type" article, i want to call nodes by another id , but this id is in another table, should i join tables , or it is some other way to do this

$type = "article";

          $build = array();
          if ($nodes = node_load_multiple(array(), array('type' => $type))); {
              $build['nodes'] = node_view_multiple($nodes, 'teaser');

In Drupal 7 conditions are deprecated, it is preferable to use EntityFieldQuery to retrieve a list of entity IDs. You can see more here:
About EntityFieldQuery

In this answer you can see an example: What's the proper use of EntityFieldQuery?

In Drupal 8 you can do something like that:

$nids = \Drupal::entityQuery('node')
->condition('your_taxonomy_field', 'your taxonomy id')
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

I hope it helps


Yes i have figure it out, thank you, here is it

function category1_page() {

      $query = new EntityFieldQuery();

          ->entityCondition('entity_type', 'node')
          ->entityCondition('bundle', 'article')
          ->fieldCondition('field_blog_category', 'tid', 4);

      $result = $query->execute();

      $build = array();
      if ($nodes = node_load_multiple(array_keys($result['node']))); {
          $build['nodes'] = node_view_multiple($nodes, 'full');

    return $build;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.