Custom Fields
Re-Envisioned
Support Meta Box Builder retrieving image in post from new field

  • Creator
    Topic
  • #23604
    Resolved Steve
    Participant

    Hi, 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.

Viewing 8 replies - 11 through 18 (of 18 total)
  • Author
    Replies
  • #23702
    Long Nguyen
    Moderator

    Hi,

    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"]
    
    #23703
    Steve
    Participant

    Hi 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?

    #23712
    Long Nguyen
    Moderator

    Hi 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

    #23715
    Steve
    Participant

    Hi 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

    #23719
    Long Nguyen
    Moderator

    Hi,

    Shortcode is a shortcut code that helps you run the helper function rwmb_meta without touching the code, it uses to display the field value for a specific case/post.

    If you want to show the field value of all posts (portfolios) in a shortcode, please create a custom shortcode to show all portfolios and its custom field. Follow this documentation https://codex.wordpress.org/Shortcode_API.

    #23741
    Steve
    Participant

    Thanks Long but this does not explain how we pull the postID from each object automatically, can you please advise how we can add the postID to a Metabox custom field automatically?

    #23811
    Steve
    Participant

    Im using this shortcode to display a single image: [rwmb_meta id="field_id" object_id="15"]

    how would I add a class to this image via the shortcode?

    #23813
    Long Nguyen
    Moderator

    Hi,

    The shortcode does not support to add the custom class. You can try to wrap the shortcode in a <div> tag. Just like:

    <div class="my-custom-class">
        [rwmb_meta id="field_id" object_id="15"]
    </div>
    

    Or use the Builder to add the custom class to the field https://share.getcloudapp.com/X6u0nXzj.

Viewing 8 replies - 11 through 18 (of 18 total)
  • You must be logged in to reply to this topic.