taxonomy_get_children drupal 8

To retrieve the children of a taxonomy term in Drupal 8, you can use the taxonomy_get_children() function. However, please note that in Drupal 8, this function has been deprecated and replaced with a new approach using the EntityQuery class.

Here's an example of how you can retrieve the children of a taxonomy term using the EntityQuery class in Drupal 8:

$term_id = 123; // Replace 123 with the actual term ID you want to retrieve the children for

$term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$query = \Drupal::entityQuery('taxonomy_term')
  ->condition('vid', 'your_vocabulary_machine_name')
  ->condition('parent', $term_id);

$term_ids = $query->execute();
$terms = $term_storage->loadMultiple($term_ids);

In the code above, make sure to replace 'your_vocabulary_machine_name' with the machine name of your vocabulary.

This code will retrieve the term IDs of the children of the specified term and load the corresponding term entities. You can then work with these term entities as needed.

Please note that it's important to use the appropriate vocabulary machine name and term ID in your code to retrieve the correct children.