In Drupal 7, we are using taxonomy_select_nodes() to get a list of nodes using a taxonomy term.

What is the equivalent in versions after Drupal 7?


Use loadByProperties():

$nodes = \Drupal::entityTypeManager()
  ->loadByProperties(['field_tags' => $tid]);
  • Does it work also for field values?
    – apaderno
    Apr 15 '17 at 8:04
  • @kiamlaluno, this works for all field values.
    – 4k4
    Apr 15 '17 at 8:09
  • It's working but when i Switch language same node id return .I need to return nid behalf of language . Apr 20 '17 at 4:49
  • In D8 all translations of a node have the same node id. When you render the node the language switches automatically to the current language.
    – 4k4
    Apr 20 '17 at 6:20

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.