Create a WordPress Image Gallery with the File Upload Form Element
We can use the "File" form element to enable upload of multiple images in the form. All Image ID's get stored in the custom field (post met). You can access the File ID's like normal post meta with the get_post_meta() function. Please read the documentation for more informations
How To Display Form Element Values in the Post
In the below examples we use the "File" form element to collect images and than use the WordPress gallery shortcode to hook the gallery under the content or use as shortcode.
You can copy the function to your function.php in your theme to make this work.
In this example we create a function to hook the gallery under the content of the post
Change the "_bf_form_slug" to the form slug and the "FORMELEMENTSLUG" to the slug of the "File" form element you want to use for the gallery.
In the next example we create a new shortcode for the gallery
Change the "FORMELEMENTSLUG" to the slug of the "File" form element you want to use for the gallery.
Use Case 1: Use as Shortcode in Post, Pages, Widgets, etc: Shortcodes Example: [my_bf_gallery_shortcode form_element_slug="FORMELEMENTSLUG"]
Use Case 2: You can use the shortcodes in your templates with the do_shortcode function. Please see the WordPress documentation for do_shortcode. This enables you to define the layout and design and decide exactly where in your templates the gallery gets displayed.
Use Case 2: You can use the shortcodes in your templates with the do_shortcode function. Please see the WordPress documentation for do_shortcode. This enables you to define the layout and design and decide exactly where in your templates the gallery gets displayed.