Last active
June 9, 2018 16:46
-
-
Save algotrader-dotcom/674bc6b10b646be5633f08e91fce9546 to your computer and use it in GitHub Desktop.
Drupal 8 - Load term by name programtically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Drupal\Core\DrupalKernel; | |
| use Symfony\Component\HttpFoundation\Request; | |
| $autoloader = require_once 'autoload.php'; | |
| $kernel = new DrupalKernel('prod', $autoloader); | |
| $request = Request::createFromGlobals(); | |
| $response = $kernel->handle($request); | |
| use Drupal\node\Entity\Node; | |
| use Drupal\file\Entity\File; | |
| use Drupal\taxonomy\Entity\Term; | |
| // Load term by name | |
| $value = 'test 2'; | |
| $terms = taxonomy_term_load_multiple_by_name($value,'tags'); | |
| $term_ids = []; | |
| foreach($terms as $term){ | |
| //print $term->get('tid')->value."\n"; | |
| $term_ids[] = $term->get('tid')->value; | |
| } | |
| // Delete term by id | |
| // entity_delete_multiple('taxonomy_term',$term_ids); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment