将Google地图标记链接到帖子ID

时间:2018-01-11 07:17:23

标签: php wordpress advanced-custom-fields

我已将ACF用于商店谷歌地图地址。现在我将所有地图都放在存档页面中,并将其用作多个标记。

让我举个例子。

Project One有地址 - 印度 项目二有地址 - 英国 项目三有地址 - 美国 项目四有地址 - 中国

在所有项目显示为

的页面中

第一个项目 项目二 项目三 项目四

在该页面中,我将显示所有地址为印度,英国,美国,中国的谷歌地图

现在,我想在点击地图标记时获得项目链接。

这就是我在做的事。

function projects_location( ) {

    $locations = "[av_google_map height='500px' zoom='14' saturation='-100' hue='' zoom_control='aviaTBzoom_control' maptype_control='' maptype_id='']";

            $args = array( 'post_type' => 'project', 'posts_per_page' => -1 );

            $loop = new WP_Query( $args );  
            while ( $loop->have_posts() ) : $loop->the_post();
                $id = get_the_id();
                $location_map = get_field( 'location_map', $id  );
                $address = explode(',', $location_map['address']);
                $locations .= "[av_gmap_location address='".$location_map['address']."' city='".$address[1]."' country='".$address[2]."' long='".$location_map['lng']."' lat='".$location_map['lat']."' marker='3478' imagesize='40' projecturl ='".get_permalink($id)."'][/av_gmap_location]";
            endwhile;

    $locations .= "[/av_google_map]";
    return do_shortcode($locations);
}
add_shortcode( 'projects-loc', 'projects_location' );

请参阅" projecturl",这是由我添加的,它也会出现在前端链接中。

av_google_map['0']['marker']['0']['projecturl'] = "get the Project url"

现在我正在尝试通过此

获取网址
jQuery('.gmnoprint img').click( function() {
    obj = av_google_map[0]["marker"][0];
    console.log(obj);
    console.log('lgfgf');
});

但它不起作用。请告诉我获取网址的方法或通过这种方式无法实现。

谢谢。

0 个答案:

没有答案