- This topic has 3 replies, 2 voices, and was last updated 2 years, 6 months ago by
Steve.
-
AuthorPosts
-
-
July 15, 2019 at 3:35 pm #9442
shayneolMemberHello,
I’m still not sure what’s going on with the update script, but I found out that there’s an issue with having only a File-Upload field inside of a group, which is how mine is setup. If I add any other input field to the group, the images in the file-upload field are saved and displayed correctly. For example, if I change my code to the following and re-add the files in the file-upload field, everything saves and displays fine, but then I will have a random input field on the screen:
piklist('field', array( 'type' => 'group' ,'field' => 'featured_images' ,'label' => __('Featured Images For Product List Page', 'piklist-demo') ,'add_more' => false ,'template' => 'field' ,'fields' => array( array( 'type' => 'file' ,'field' => 'images' //,'scope' => 'post_meta' ,'label' => __('Featured Images For Product List Page', 'piklist-demo') ,'columns' => 12 ,'options' => array( 'modal_title' => __('Add File', 'piklist-demo') ,'button' => __('Add', 'piklist-demo') ) ) ,array( 'type' => 'text' ,'field' => 'city' ,'label' => __('City', 'piklist-demo') ,'columns' => 5 ) ) ));I remember that I set this up this way because if I don’t put the file-upload field into a group, it won’t let me output all of the images onto the front-end.
For example:
If I just use the following code (without a group) and save multiple files in the file-upload field, it will only output the ID of the first image uploaded.piklist('field', array( 'type' => 'file' ,'field' => 'temp-upload' ,'scope' => 'post_meta' ,'template' => 'field' ,'label' => 'Media Uploader' ,'options' => array( 'modal_title' => 'Add File(s)' ,'button' => 'Add' ) ));<?php $temp_image = get_post_meta(get_the_ID(), 'temp-upload', true); ?> <pre><?php print_r($temp_image)?></pre>I’ve had this issue on multiple sites, so I know it’s not specific to this project alone. Thanks for your help on resolving this.
-
July 16, 2019 at 9:58 am #9443
SteveKeymasterI split this out into a new topic since it’s not related to the original.
So, I’m not 100% clear on the issue, but here are two things I noticed:
1) There’s no benefit to having one file in a group field. Just use the field.
2) Usingget_post_metawith the last parameter set totruewill only return one value. Change it tofalse: -
July 18, 2019 at 2:05 pm #9450
shayneolMemberOh shoot! That was it. I didn’t even notice that. Thanks!!
-
July 18, 2019 at 5:52 pm #9451
SteveKeymasterGreat. Marking this resolved
-
-
AuthorPosts
- The topic ‘Upload field issue’ is closed to new replies.