var point = new GLatLng(49.295308,-123.149297);
var marker = createMarker(point,"Site Title",'<div class="maptext"><p class="prepend-top caption">Title<\/p>
<?php $the_query = new WP_Query('category_name=featured');
while ($the_query->have_posts()) : $the_query->the_post();?>
<?php if ( get_post_meta($post->ID, 'site-description', true) ) { ?>
<?php echo get_post_meta($post->ID, 'site-description', $single = true); ?>
<?php } ?>
<\/div>')
map.addOverlay(marker);
好吧,萨法兹对他的原始反应是正确的,我得到了一个解析错误,它破坏了它。最终奏效的是:
var point = new GLatLng(48.134239,-122.764769);
var marker = createMarker(point,"Port Townsend Marine Science Center",'<div class="maptext"><?php $the_query = new WP_Query('post_name=test-site');
while ($the_query->have_posts()) : $the_query->the_post();?><?php if ( get_post_meta($post->ID, 'map-content', true) ) { ?><?php echo get_post_meta($post->ID, "map-content", $single = true); ?><?php } ?><?php endwhile; ?><\/div>')
map.addOverlay(marker);
---更新---
我只是想补充一点,我发现这是我抓取帖子的最佳方式,因为我总是希望有一个特定的链接到该标记:
var point = new GLatLng(48.5139,-123.150531);
var marker = createMarker(point,"Lime Kiln State Park",
'<?php $post_id = 182;
$my_post = get_post($post_id);
$title = $my_post->post_title;
echo $title;
echo $my_post->post_content;
?>')
map.addOverlay(marker);