0

Drupal 8 has term method loadproperties which works for custom fields; however, how can I use it (or can I use it) to load by substrings. For example if I have a field: field_full_name and I want to load all terms that start with a string "David*" is this possible ... if not how?

Thanks ~

1 Answer 1

1

You can use the SQL operator LIKE in an entity query and append the wildcard % to the string:

$result = \Drupal::entityQuery('taxonomy_term')
  ->condition('name', 'david%', 'LIKE')
  ->condition('vid', 'tags')
  ->execute();

$terms = \Drupal::entityTypeManager()
  ->getStorage('taxonomy_term')
  ->loadMultiple($result);

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.