Custom Fields
Re-Envisioned
Support MB Blocks Save meta values in database

This topic contains 9 replies, has 2 voices, and was last updated by  closemarketing 1 month ago.

  • Creator
    Topic
  • #16511
    Resolved
    closemarketing
    Participant

    How can I save the meta values from the gutenberg block as a meta value?

    Is it possible? That would be very nice, becouse you can use it to filter a post type or similar.

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #16512

    closemarketing
    Participant

    Or, Could I use meta values in template block?

    #16530

    Anh Tran
    Keymaster

    Hi,

    Unfortunately, blocks can save data only to its own. The post meta allows only 1 pair of key-value, but you can add many blocks in a post. So, if that’s possible, that might be confusing.

    In order to use meta values in a block template, you can simple register meta fields normally with Meta Box, and use helper functions rwmb_meta to get them to show.

    #16531

    closemarketing
    Participant

    So, I can use rwmb_meta in template block?

    #16532

    closemarketing
    Participant

    Would you add in your roadmap to save meta values as well?

    #16536

    Anh Tran
    Keymaster

    So, I can use rwmb_meta in template block?

    Yes, you can.

    Would you add in your roadmap to save meta values as well?

    As I explain in the previous reply, this doesn’t work because you can add multiple instances same block. If one field in each blog has different values, then there’s no way to decide which value will be save in the post meta.

    #16537

    closemarketing
    Participant

    How can i use rwmb_meta? Could you give me an example?

    #16538

    closemarketing
    Participant

    What are the limitations for template.php? I’m trying to use rwmeta and WordPress Functions like the_excerpt, the_post_thumbnail, etc. But they does not work.

    #16578

    Anh Tran
    Keymaster

    Hi, please see this video: https://www.loom.com/share/80fa3ff5dc6149a9bd2cb640a62aa69c. I demonstrate how to use rwmb_meta, rwmb_the_value in the block render callback.

    Just a note: when you use these helper functions, don’t forget to use the parameter $post_id. If you want to use other WordPress functions, remember to use it as well, or you’ll get the wrong info when preview the block in the edit screen.

    #16596

    closemarketing
    Participant

    Nice! that’s all that I need!

    Congratulations for the plugin.

Viewing 9 replies - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.