diff --git a/Classes/Task/GridelementsOrphanedChildFixer.php b/Classes/Task/GridelementsOrphanedChildFixer.php
new file mode 100644
index 0000000..747218e
--- /dev/null
+++ b/Classes/Task/GridelementsOrphanedChildFixer.php
@@ -0,0 +1,94 @@
+getQueryBuilderForTable('tt_content');
+ $queryBuilder->getRestrictions()
+ ->removeAll()
+ ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+ $rows = $queryBuilder
+ ->select('tt_content.uid AS uid', 't2.colpos AS colpos')
+ ->from('tt_content')
+ ->join('tt_content', 'tt_content', 't2',
+ $queryBuilder->expr()->eq('tt_content.tx_gridelements_container',
+ $queryBuilder->quoteIdentifier('t2.uid')
+ )
+ )
+ ->where(
+ $queryBuilder->expr()->gt(
+ 'tt_content.tx_gridelements_container',
+ 0
+ ),
+ $queryBuilder->expr()->eq(
+ 'tt_content.colpos',
+ -1
+ ),
+ $queryBuilder->expr()->neq(
+ 't2.CType',
+ $queryBuilder->createNamedParameter('gridelements_pi1')
+ )
+ )
+ ->executeQuery()
+ ->fetchAllAssociative();
+
+ foreach ($rows as $row) {
+ $uid = (int)($row['uid']);
+
+ $connection = $connectionPool
+ ->getConnectionForTable('tt_content');
+ $connection->update(
+ 'tt_content',
+ [
+ 'colpos' => (int)($row['colpos'] ?? 0),
+ 'tx_gridelements_container' => 0,
+ 'hidden' => 1,
+ ],
+ [
+ 'uid' => $uid,
+ ],
+ [
+ Connection::PARAM_INT,
+ Connection::PARAM_INT,
+ Connection::PARAM_INT,
+ Connection::PARAM_INT,
+ ]
+ );
+ }
+
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf
index ccf182f..863e714 100644
--- a/Resources/Private/Language/locallang.xlf
+++ b/Resources/Private/Language/locallang.xlf
@@ -37,6 +37,12 @@
Recalculates the value of tx_gridelements_children due to buggy container update behaviour of Cut/Copy/Paste and/or Drag/Drop methods.
+
+ Gridelements Orphaned Children Fixer
+
+
+ Fixes content elements which are a child of a content element which is no longer a gridelement. These elemens will then be displayed in BE again, but are hidden.
+