Jump to content

php in WP loop problem


VinceGledhill

Recommended Posts

Hello People.

I have a site that I am trying to paste multiple pins on a single map in a wordpress site, using cbxgooglemap plugin and advanced custom fields for my lat and long information.

The following code works fine for one pin, on one map.

echo do_shortcode('[cbxgooglemap lat="'.get_field('latitude').'" lng="'.get_field('longitude').'" ]');

However, when I try to post it within the loop, I simply get multiple maps, instead of one map, with multiple pins.  Here is the code that doesn't work correctly, it gives me 3 maps.

<?php 

$justMap = new WP_Query(array(
'posts_per_page'=> 3,
'post_type' => 'airfield_card'
));
while($justMap->have_posts()){
    $justMap->the_post(); 
echo do_shortcode('[cbxgooglemap lat="'.get_field('latitude').'" lng="'.get_field('longitude').'" ]'); 
 }

?>   

Please can someone tell me how to alter the code so that a single map is outside the loop, but still embedding each pin from the loop.

Kind Regards
VinceGledhill

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.