1

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?

1 Answer 1

1

Use loadByProperties():

$nodes = \Drupal::entityTypeManager()
  ->getStorage('node')
  ->loadByProperties(['field_tags' => $tid]);
4
  • Does it work also for field values?
    – apaderno
    Commented Apr 15, 2017 at 8:04
  • @kiamlaluno, this works for all field values.
    – 4uk4
    Commented Apr 15, 2017 at 8:09
  • It's working but when i Switch language same node id return .I need to return nid behalf of language . Commented Apr 20, 2017 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.
    – 4uk4
    Commented Apr 20, 2017 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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