Issue getting group to save/load on front end
- This topic has 3 replies, 2 voices, and was last updated 8 years, 11 months ago by
jonwatson87.
-
AuthorPosts
-
May 31, 2016 at 4:33 AM #3224
jonwatson87
ParticipantOkay, 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 { }
May 31, 2016 at 4:44 AM #3225jonwatson87
ParticipantOkay, loading fine on the front end now! Must've mis-copied/pasted something.
Still not letting me add more than 1 group record, however...
June 1, 2016 at 10:03 AM #3242Anh Tran
KeymasterHi @jonwatson87, can you please refresh your browser to clear the cache? Someone asked me the same question and the problem was the JavaScript cache.
June 1, 2016 at 6:32 PM #3254jonwatson87
Participant100% correct! Sorry, Anh! Feel like an idiot now! Clearing the cache is usually the first thing I do! XD
Thanks so much for the help!
-
AuthorPosts
- The topic ‘Issue getting group to save/load on front end’ is closed to new replies.