Skip to content

Instantly share code, notes, and snippets.

@tyxla
Created February 24, 2016 07:31
Show Gist options
  • Save tyxla/7c9c7691e6101375ea07 to your computer and use it in GitHub Desktop.
Save tyxla/7c9c7691e6101375ea07 to your computer and use it in GitHub Desktop.
Displaying nested complex Carbon Fields in the front-end templates
<?php $sections = carbon_get_post_meta( get_the_ID(), 'lk_section', 'complex' ); ?>
<?php if ( ! empty( $sections ) ): ?>
<?php foreach ( $sections as $section ): ?>
<section class="<?php echo esc_attr( $section['class'] ); ?>">
<?php if ( ! empty( $section['lk_row'] ) ): ?>
<?php foreach ( $section['lk_row'] as $row ): ?>
<div class="<?php echo esc_attr( $row['class'] ); ?>">
<?php if ( ! empty( $row['lk_column'] ) ): ?>
<?php foreach ( $row['lk_column'] as $column ): ?>
<div class="<?php echo esc_attr( $column['class'] ); ?>">
... column content goes here ...
</div>
<?php endforeach ?>
<?php endif ?>
</div>
<?php endforeach ?>
<?php endif ?>
</section>
<?php endforeach ?>
<?php endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment