Okay, two issues with my groups. Firstly, I can't save more than 1 set of records. Every time I "Add more" the first record is replaced and none of the others save.
Secondly, it doesn't want to display properly on the front end. I want it to display conditionally, if there are records.
What have I messed up?
//Panelists
$meta_boxes[] = array(
'title' => 'Panelists',
'context' => 'normal',
'priority' => 'high',
'post_types' => 'events',
'desc' => '(drag to reorder)',
'fields' => array(
array(
'id' => 'radix_panelists',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'fields' => array(
array(
'name' => 'Name',
'id' => $prefix . 'panelistname',
'type' => 'text',
'desc' => 'Name of panelist',
),
array(
'name' => 'URL',
'id' => $prefix . 'panelisturl',
'type' => 'text',
'desc' => 'Link or mailto: for panelist',
),
array(
'name' => 'Profile Pic',
'id' => $prefix . 'panelistpic',
'type' => 'file_input',
'desc' => 'Profile picture of panelist',
),
),
),
),
);
return $meta_boxes;
And then on the page template:
// Speakers
$speakergroup = rwmb_meta( 'radix_panelists' );
if ( ! empty( $speakergroup ) ) {
echo '<div class="eventspeakers">';
echo '<h1>Speakers</h1>';
// Call Panelist Data
foreach ( $speakergroup as $speakerdata ) {
echo '<div class="eventspeaker">';
if ( ! empty ($speakerdata['radix_panelistpic'])) {
$attachment_id = attachment_url_to_postid( $speakerdata['radix_panelistpic'] );
list( $src ) = wp_get_attachment_image_src( $attachment_id, 'thumbnail' );
echo '<a href="' . $speakerdata['radix_panelisturl'] . '" target=_blank><img src="' . $src . '"></a>';
} else {
echo '<a href="' . $speakerdata['radix_panelisturl'] . '" target=_blank><img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/default-profile.jpg"></a>';
}
echo '<div class="speakername"><a href="' . $speakerdata['radix_panelisturl'] . '" target=_blank>' . $speakerdata['radix_panelistname'] . '</a></div>';
echo '</div>';
}
echo '</div>';
}
else {
}