mcguffin / acf-openstreetmap-field

WordPress ACF Field for OpenStreetMap
https://wordpress.org/plugins/acf-openstreetmap-field/
GNU General Public License v3.0
107 stars 21 forks source link

Show a general map with all markers from all posts #114

Open jan1980 opened 3 months ago

jan1980 commented 3 months ago

Hello, could you show me an easy way to show a "general map" with all markers from all posts? I've been trying this to no avail (it only works when I add a single ID):

add_shortcode( 'open_street_map_special', 'osm_spec' );

    function osm_spec_init(){

        function osm_spec() {
            $all_post_ids = get_posts(array(
                'fields'          => 'ids',
                'posts_per_page'  => -1,
                'post_type' => 'it-suppliers'
            ));

            $map_ids = implode(',', $all_post_ids);

            $short = '[acf field="it_company_address" post_id="'.$map_ids.'"]';
            echo do_shortcode($short);
        }
    }

add_action('init', 'osm_spec_init');