I have a clone field that is used in 2 places:
– Homepage
– Flexible Content field
I have a template partial that displays the fields from the clone.
I include the partial in the Homepage template and I include the partial in the flexible content field.
The partial uses get_field
to display each field.
When included in the homepage, the fields are displayed.
When included in the flexible content field, the fields are not displayed, because it needs to use get_sub_field
.
Is there a way to have 1 clone field partial that can be used for a page, and also within a flexible content field?
Thanks
Homepage
get_template_part( 'components/clones/split-col');
Flexible content
if( have_rows('page_builder_content_blocks') ):
while ( have_rows('page_builder_content_blocks') ) : the_row();
if( get_row_layout() == 'page_builder_split_column' ):
get_template_part( 'components/clones/split-col');
endif;
endwhile;
endif;
Partial
<div>
<?php if (get_field('split_col_title')) : ?>
<h2><?php the_field('split_col_title'); ?</h2>
<?php endif; ?>
<?php if (get_field('split_col_text')) : ?>
<?php the_field('split_col_text'); ?>
<?php endif; ?>
</div>