Dynamically add [leaflet-marker]
-
Hi,
I try to dynamically create a map with markers for all my Custom Post Types with adress.If I put this :
<?= do_shortcode('[leaflet-map fitbounds]'); ?> <?= do_shortcode('[leaflet-marker address="57000 Metz"]'); ?> <?= do_shortcode('[leaflet-marker address="12 promenade des Canaux 54 000 Nancy"]'); ?>
It works but it’s not dynamic.
If I put this :
<?php $args = array( 'post_type' => 'franchise', 'posts_per_page' => -1, 'post_status' => 'publish' ); $the_query = new WP_Query($args); if ( $the_query->have_posts() ){ while ( $the_query->have_posts() ){ $the_query->the_post(); $adresse = get_field('adresse').' '.get_field('code_postal').' '.get_field('ville'); print(do_shortcode('[leaflet-marker svg color="#fff" background="#000" iconClass="fas fa-map-marker" address="'.$adresse.']')); ?> <?php } wp_reset_postdata(); } ?>
It is not working, I think js is called before my loop is ended.
How can I do that ?
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Dynamically add [leaflet-marker]’ is closed to new replies.