Skip to content

Instantly share code, notes, and snippets.

@topher1kenobe
Created December 8, 2024 20:17
Show Gist options
  • Save topher1kenobe/4ede89488143bbd78168f15c8528e2ac to your computer and use it in GitHub Desktop.
Save topher1kenobe/4ede89488143bbd78168f15c8528e2ac to your computer and use it in GitHub Desktop.
Using MetaBox.io to create subsgroups.
<?php
$groups = rwmb_meta( 'ie-slider-sliders' );
foreach ( $groups as $group ) {
// Field slider:
$subgroups = $group[ 'slider' ] ?? '';
foreach ( $subgroups as $subgroup ) {
// Field title:
echo $subgroup[ 'title' ] ?? '';
// Field image:
$image_ids = $subgroup[ 'image' ] ?? [];
?>
<h3>Uploaded images</h3>
<ul>
<?php foreach ( $image_ids as $image_id ) : ?>
<?php $image = RWMB_Image_Field::file_info( $image_id, [ 'size' => 'thumbnail' ); ?>
<li><img src="<?php echo $image['url']; ?>"></li>
<?php endforeach ?>
</ul>
<?php
// Field caption:
echo $subgroup[ 'caption' ] ?? '';
// Field description:
$values = $subgroup[ 'description' ] ?? '';
foreach ( $values as $value ) :
echo do_shortcode( wpautop( $value ) );
endforeach;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment