I am using Paragraphs module and I can't delete paragraph type until I delete the content of the paragraph. I can use admin/modules/uninstall/entity/paragraph, but this will delete the paragraphs of all types.

  • Try using Views Bulk Operations – No Sssweat Jul 11 '17 at 22:14
  • I have edited the title. The entity type would be paragraph, a certain paragraph type is in general terms a bundle. – Neograph734 Jul 11 '17 at 22:15

There are some examples of removing nodes of a certain content type. In that case node is the entity type and article could be bundle (content type). This is no different. paragraph is the entity and [paragraph type] is the bundle.

For instance this post: https://stackoverflow.com/questions/34593060/drupal-8-delete-all-nodes-of-the-same-type

There are a few alternatives listed, but I suppose this should work:

$paragraphs = \Drupal::entityTypeManager()
    ->loadByProperties(array('type' => 'your_paragraph_type')); // System name

foreach ($paragraphs as $paragraph) {
  • Thanks Neograph734, That's mean the solution will be custom code, I will add button inside each Paragraph type edit form to delete all Paragraphs. – Abdulla Abu Zakham Jul 12 '17 at 9:32
  • It depends on what you prefer. If you want some interface, the Views Bulk Option suggested by No Sssweat above might also work. It would allow you to create a view of paragraphs, add a condition for a type, add the VBO checkbox and use the delete action to delete them all. Might be more work to click together, but uses the batch api, which might work better for many many paragraphs. – Neograph734 Jul 12 '17 at 9:35
  • I will check if I can delete Paragraphs using views and VBO and get back to you. Thanks in advance. – Abdulla Abu Zakham Jul 12 '17 at 9:46
  • @AbdullaAbuZakham If it works, you could add it as your own answer. Would be nice if you could include some good instructions :) – Neograph734 Jul 12 '17 at 9:47
  • 1
    after checking views and all option inside views, It's kind of impossible to delete paragraphs using views. I Think the best solution is implement custom button inside each paragraph type to delete all paragraphs. Thanks. – Abdulla Abu Zakham Jul 12 '17 at 12:59

This seemed to work for me ...

$paragraph_types = array('your_paragraph_types');
foreach ($paragraph_types as $paragraph_type) {
    $para_type = \Drupal::entityManager()->getStorage('paragraphs_type')->load($paragraph_type);
    if ($para_type) {
  • Seems this code delete paragraph type, not paragraph entities. – Abdulla Abu Zakham Oct 30 '17 at 22:23

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.