retrieving image in post from new field
Support › MB Builder › retrieving image in post from new fieldResolved
- This topic has 18 replies, 2 voices, and was last updated 4 years, 3 months ago by
Long Nguyen.
-
AuthorPosts
-
December 18, 2020 at 4:25 AM #23604
Steve
ParticipantHi, I have purchased meta box builder and I have added file upload as a new file and it works fine, however im using the grid template builder with WPbakery page builder and I have added a custom field and in the input I have tried adding both the ID of the new metafield and also this shortcode [rwmb_meta id="single_image_ngobiqx24ya"] but neither seem to be pulling the image from the new field, are you able to advise? thank you.
December 18, 2020 at 11:18 AM #23605Long Nguyen
ModeratorHi Steve,
WPBakery is a premium plugin so I've not checked the shortcode with this builder before. Please share a copy of this plugin via the contact form https://metabox.io/contact/, I will test the shortcode on my end.
FYI, I also test the shortcode with Elementor and it works as well.
December 18, 2020 at 3:31 PM #23606Steve
ParticipantHi Long, Thanks for getting back to me. I cannot send you the plugin as this is art of a theme bundle, i can send you the login credentials though so you can try yourself, I tried adding the shortcode directly to the page but nothing is displaying. Is it possible to send a private reply on here with the login details?
December 18, 2020 at 4:52 PM #23609Steve
ParticipantAlso just to mention the field type I added is "single image" im not sure if this makes a difference to my shortcode?
December 19, 2020 at 8:15 AM #23617Long Nguyen
ModeratorHi,
This is a public forum so you should share the login credentials via this form https://metabox.io/contact/.
December 19, 2020 at 4:26 PM #23633Steve
ParticipantThanks Long I just sent the login details via the contact form, please confirm receipt of this information.
December 19, 2020 at 10:22 PM #23638Long Nguyen
ModeratorGot the issue. You've added the prefix for the field ID, screenshot https://share.getcloudapp.com/DOuodQb7.
So the field ID when using the shortcode is
flipimagesingle_image_ngobiqx24ya
. Get more details in the tab Code of Field Groups.add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = 'flipimage'; $meta_boxes[] = [ 'title' => esc_html__( 'Flip Image', 'text-domain' ), 'id' => 'flip-image', 'post_types' => ['post', 'portfolio'], 'context' => 'side', 'priority' => 'low', 'fields' => [ [ 'id' => $prefix . 'single_image_ngobiqx24ya', //here 'type' => 'single_image', 'name' => esc_html__( 'Single Image', 'text-domain' ), ], ], ]; return $meta_boxes; }
December 19, 2020 at 10:51 PM #23640Steve
ParticipantThank you! where did you add this function code as I will be happy to just remove the prefix to make it easier.
December 20, 2020 at 9:50 PM #23648Long Nguyen
ModeratorHi,
The PHP code is generated by the Builder, you can share it with other sites that do not have the MB Builder extension. And I've checked the code to see the settings of the meta box and custom fields. You can learn to use it in the documentation https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code.
December 21, 2020 at 6:37 PM #23671Steve
ParticipantHi Long, how can I pass the post ID to the shortcode dynamically so the grid can associate the correct post ID in each shortcode/post?
December 22, 2020 at 3:52 PM #23698Steve
ParticipantHi Long, I hope you’re well. are you able to get back to me on the last message?
December 22, 2020 at 9:33 PM #23702Long Nguyen
ModeratorHi,
I also receive your message via the ticket system so I will reply here and close the ticket.
If you are building a grid template and want to include the shortcode to show the custom field of a post, you have to pass the fixed post ID as the
object_id
value.[rwmb_meta id="field_id" object_id="15"]
December 22, 2020 at 9:39 PM #23703Steve
ParticipantHi Long please do not close the ticket as it is not complete and not solved.
As I mentioned it is not possible to write the fixed post ID in the grid builder because the grid serves multiple posts within the same grid design, lets say 10 posts are shown through the same grid so for this to work the objectID must be passed through in the same way like the field ID is in the shortcode, do you see what I mean?December 23, 2020 at 10:37 AM #23712Long Nguyen
ModeratorHi Steve,
Let me explain more about your case.
- You have 10 posts (portfolio) that have the custom field single image.
- You create a grid by the builder and want to add the shortcode to the grid.
- You create a page (Drink) by the builder and include the grid.
So in the grid, you have to insert 10 shortcodes with the
object_id
(portfolio ID) to show each portfolio such as:[rwmb_meta id="single_image" object_id="1"] [rwmb_meta id="single_image" object_id="3"] [rwmb_meta id="single_image" object_id="12"]
If not insert the
object_id
the shortcode will take the ID of the page (Drink) to pass to the shortcode and show the field value but the page does not have the field value.Get more details in the documentation https://docs.metabox.io/shortcode/.
object_id The object ID. Optional. If not defined, then the current object ID is used
December 23, 2020 at 2:23 PM #23715Steve
ParticipantHi Long, this is not possible the grid will be showing hundreds of different portfolio items, my client needs to be able to add new portfolio items and they display through the grid design, we cannot add a new shortcode every time they wish to add a new site,, this is not realistic, even if we have to add a new metafielcd called post ID, is it not possible to automatically refill this field with the post id/objectID?
A second option is using the grid builder custom fields which is currently working and this is displaying the correct records and fields for each item, the text fields all display fine but when I add the custom key for the image field rather than it showing the image it just shows numbers instead? how can we fix this? on the below link you will see the data is displaying correctly in the first white box but if you look for the numbers on this page (9596) this should be the image displaying: shorturl.at/cjIW3
-
AuthorPosts
- You must be logged in to reply to this topic.