Why is the programmatically removed paragraph item still showing after adding a new paragraph to the node? I have a paragraph field in a node with unlimited add paragraph. I am removing these paragraph programatically. Its removing but when I am adding a new paragraph its adding blank paragraph along with. 

I am using this code to remove paragraph

use Drupal\paragraphs\ParagraphInterface;
use Drupal\paragraphs\Entity\Paragraph;

$ids = \Drupal::entityQuery('paragraph')-&gt;execute();
foreach ($ids as $id) {
  $paragraph = Paragraph::load($id);
  if ($paragraph instanceof ParagraphInterface) {
    $paragraph-&gt;delete();
  }
}
You have 3 tables doing the job: a table which stores node data, a table which stores paragraphs data, and a table which stores relation about node and paragraphs. Now you emptied the table which stores the paragraphs data, but the node-paragraph relation table is still there. So if you have added 4 paragraphs to a node and deleted that 4 paragraphs, still drupal assumes there should be 4 paragraphs attached to that node.



so if you want to delete them entirely you have to fetch node data which has "paragraph" field value, delete field value from each node and save it.

so here are steps : 
you can run a database query on field table, and get all node-paragraph relations. now you have a list of all nodes that have a paragraphs, so having node ids and paragraph ids you can first remove paragraphs from node using a code like this:

$node = Node::load($nid);
$node-&gt;FIELD_NAME-&gt;setValue(array());
$node-&gt;save();


and then delete correspond paragraphs using a code like the one you mentioned. of course you don't need another query as you have paragraph ids. 



if you don't mind removing all paragraph values from database and only don't like them to be shown in your node, then you can write an entityquery like this :

$query = \Drupal::entityQuery('node');
$query-&gt;exists('field_to_check');//Check A field value is NOT NULL
$ids = $query-&gt;execute();


so it gives you all nodes which has value for that field, then you only can run :

foreach($ids as $nid) {
  $node = Node::load($nid);
  $node-&gt;FIELD_NAME-&gt;setValue(array());
  $node-&gt;save();
}