Displaying the map with a shortcode

Support General Displaying the map with a shortcode

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #31378
    NataliaNatalia
    Participant

    Hi! I have a custom post type in WP and posts have location added via "Google maps" metabox. I want to display a map from one of the posts on a page other than the single post. How can I do this with a shortcode?

    #31384
    Long NguyenLong Nguyen
    Moderator

    Hi Natalia,

    Please follow this documentation to use the helper shortcode [rwmb_meta] https://docs.metabox.io/shortcode/

    You need to pass the post ID to the shortcode to show a map from a post on a page.

    [rwmb_meta id="map_field_id" object_id="15"]
    
    #31392
    NataliaNatalia
    Participant

    Thank you 🙂 And is it possible to add args in shortcode, especially zoom?

    #31402
    Long NguyenLong Nguyen
    Moderator

    Yes, it is possible. You can add args to the shortcode as the attributes, like this

    [rwmb_meta id="map_field_id" zoom="5"]
    

    Note: you can pass other attributes to the shortcode if you want. If you do so, those attributes will be passed to rwmb_the_value() function as the 2nd parameter.

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