Custom Fields
Re-Envisioned
Support MB Blocks Cloneable group with Meta Box Builder

  • Creator
    Topic
  • #17008
    Resolved anja
    Participant

    Hi, i have a cloneable group with a cloneable singe_image field.
    I have no idea how to ouput it with mb blocks.

    Is that even possible and if so how?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #17114
    epac
    Participant

    Hello
    I’m also intested in the way to clone a group of fields in mb blocks.
    I’m not sure if it is possible but it would be a great feature.
    Many thanks

    #17151
    epac
    Participant

    Hello Anja
    With the last version of mb blocks it is possible to clone a group.

    'fields' => [
    
            [
                'id' => 'thumbs',
                'type' => 'group',
                'clone'  => true,
                'sort_clone'  => true,
                'fields' => [
    
                    [
                        'name' => "Thumb",
                        'id' => 'thumb',
                        'type' => 'file_advanced'
                        ],
                    ],
            ],
    
        ],
    

    Kind regards

    #17207
    Anh Tran
    Keymaster

    Hi Anja,

    In Meta Box Builder, assuming you have something similar to this:

    View post on imgur.com

    And you have added a block to a post with the following content:

    View post on imgur.com

    Then you can use this template code in the Meta Box Builder to display the group:

    {% set products = mb.mb_get_block_field( 'products' ) %}
    {% for product in products %}
      <h4>{{ product.product_title }}</h4>
      {% for image_id in product.product_images %}
         {% set image_url = mb.wp_get_attachment_url( image_id ) %}
         <img src="{{ image_url }}">
      {% endfor %}
    {% endfor %}

    View post on imgur.com

    Here is the result:

    View post on imgur.com

    (sorry for big images)

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.