getPreviewPost( $postId ); $postId = $previewPost->ID; } $this->render( $block, $content, $postId ); } protected function render( $block, $content, $postId ) { $repeaterFieldKey = get_field( 'meta_key' ); $repeaterFieldObject = get_field_object( $repeaterFieldKey, $postId ); $subfields = $repeaterFieldObject['sub_fields']; if( have_rows( $repeaterFieldObject['key'], $postId )): $loopCount = 0; $headers = ''; $content = ''; while ( have_rows( $repeaterFieldObject['key'], $postId )) : the_row(); $content .= ''; foreach( $subfields as $index => $subfield ) : if( $loopCount == 0 ) { $headers .= ''; $headers .= $subfield['label']; $headers .= ''; } $content .= ''; $subfieldValue = get_sub_field( $subfield['key'] ); $tl = new \AcfEngine\Core\TemplateLoader(); $tl->path = 'templates/fields/' . $subfield['type'] . '/'; $tl->name = 'default'; $tl->data = [ 'field' => $subfield, 'value' => $subfieldValue, 'postId' => $postId ]; $content .= $tl->get(); $content .= ''; endforeach; $content .= ''; $loopCount++; endwhile; $headers .= ''; endif; print '
'; print ''; print ''; print $headers; print ''; print ''; print $content; print ''; print '
'; print '
'; } }