Forum Replies Created
-
AuthorPosts
-
Sam Underwood
ParticipantIs it possible to investigate getting this added as a feature of MB Blocks? Using as much native Gutenberg features as possible would be preferable.
Sam Underwood
ParticipantIt worked perfectly.
I didn't need to useinitfor my case though.
Thanks!July 24, 2022 at 12:04 AM in reply to: ✅Image fields not carried over when duplicating a post #37154Sam Underwood
Participant// duplicate MetaBox images $images_value = rwmb_meta( 'card_images', $args = '', $post_id); foreach ( $images_value as $single_image ) { add_post_meta($new_post_id, 'card_images', $single_image, false); //rwmb_set_meta($new_post_id, 'card_images', $single_image); }add_post_metadoesn't seem to work. Maybe I'm doing something wrong?
rwmb_set_metakinda works, but it ends up only saving the last image.Sam Underwood
ParticipantUnsure what you'd like screenshots of, I can share with you a video of the issue from the frontend if that would help?
The custom field code related to the images field:
[ 'id' => 'card_images', 'name' => 'Enter the Images', 'type' => 'image_upload', 'force_delete' => false, 'max_file_uploads' => 50, 'max_status' => false, 'image_size' => 'medium', 'hidden' => [ 'card_type', '!=', 'images' ] ],The full code - https://pastebin.com/JPd3m7V9
March 31, 2022 at 5:50 AM in reply to: How to clone posts / populate form based on other posts #35382Sam Underwood
ParticipantRephrasing it:
How do I useget_post_metaandadd_post_metawith group subfields?March 30, 2022 at 2:47 AM in reply to: How to clone posts / populate form based on other posts #35363Sam Underwood
ParticipantThat wouldn't work for this case.
I have a code that's almost working. It's able to clone every field except for groups.
Here's how it's looking like so far:
// duplicate all post meta $post_meta = get_post_meta( $post_id ); if( $post_meta ) { foreach ( $post_meta as $meta_key => $meta_values ) { foreach ( $meta_values as $meta_value ) { add_post_meta( $new_post_id, $meta_key, $meta_value ); } } }How could I improve this so it'll also be able to go through the subfields?
Sam Underwood
ParticipantHi Long.
I wouldn't like to force the user to do an extra click. They won't even see the image at this point, just the "live preview".
I also thought about hiding the submit button, which might end up being the solution, although I don't like it very much.
Thanks anyway. -
AuthorPosts