<?php
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\RecordsContentObject;

$conf = [
    'tables'       => 'tt_content',
    'source'       => $elementId,
    'dontCheckPid' => 1,
];
$html = GeneralUtility::makeInstance(
    RecordsContentObject::class, $GLOBALS['TSFE']->cObj
)->render($conf);

       
