Custom Fields
Re-Envisioned
Support Meta Box Geolocation Example code for Geo location Meta fields

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 1 month ago.

  • Creator
    Topic
  • #16095

    Razib
    Participant

    Is it possible to get example code for Geo location Meta fields?

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #16109

    Anh Tran
    Keymaster

    Here you are:

    <?php
    add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
        $meta_boxes[] = [
            'title' => 'Test',
            'geo' => [
                'api_key' => 'your_api_key',
            ],
            'fields' => [
                [
                    'id' => 'address',
                    'type' => 'text',
                    'name' => 'Address',
                ],
                [
                    'id' => 'administrative_area_level_1',
                    'type' => 'text',
                    'name' => 'State',
                ],
                [
                    'id' => 'country',
                    'type' => 'text',
                    'name' => 'Country',
                ],
            ],
        ];
        return $meta_boxes;
    } );
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.