How can I show a map marker using OSM on a custom field in a custom taxonomy

Support General How can I show a map marker using OSM on a custom field in a custom taxonomyResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31362
    JonSJonS
    Participant

    I have a CPT for fixtures. I then have a custom taxonomy for venues. When viewing the a venue's single page I want to show it's details and also the map but I need help in achieving that.

    I'm using the latest Oxygen 3.9 Beta 1 which has full Meta Box support and I've created a template for the venue single page but just can't see how I can display the map.

    I've created the two fields correctly - one for the address and then used that field in the map marker field and the map is showing and saving perfectly in the WP admin area. It's the frontend I'm struggling with.

    I've tried placing a text field in the template and adding a MB custom data in there but it's not displaying anything.

    What's the technique for this? Is there custom code I can use instead? I've also tried creating a MB View containing {{ term.map_marker.rendered }} and then put the shortcode into the template but that doesn't display anything either.

    #31369
    Long NguyenLong Nguyen
    Moderator

    Hi Jons,

    You can use the helper shortcode to show the term meta (map) on the term archive page.

    [rwmb_meta id="map_marker" object_id="1234" object_type="term"]
    

    If you use the code block of Oxygen builder, you can try to use this code

    $args = array(
        'width'        => '640px',
        'height'       => '480px',
        'zoom'         => 14,
        'marker'       => true,
        'marker_title' => 'Click me',
        'info_window'  => '<h3>Title</h3><p>Content</p>.',
        'object_type' => 'term',
    );
    echo rwmb_meta( 'map_marker', $args, get_queried_object_id() );

    Refer to the documentation
    https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value
    https://docs.metabox.io/fields/osm/#template-usage

    #31376
    JonSJonS
    Participant

    Fantastic. I think the bit I was missing was the object_type. Working perfectly.

    Many thanks for the speedy response.

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