WordPress、谷歌地图和;header.php中的JavaScript
我想在WordPress网站(www.santini.se/geotimes)的入口页面上显示一个带有多个指针的谷歌地图。我在header.php的头部指定了以下Javascript代码:WordPress、谷歌地图和;header.php中的JavaScript,javascript,wordpress,google-maps,Javascript,Wordpress,Google Maps,我想在WordPress网站(www.santini.se/geotimes)的入口页面上显示一个带有多个指针的谷歌地图。我在header.php的头部指定了以下Javascript代码: <script src="http://maps.google.com/maps?file=api&v=2&key=mykey" type="text/javascript"></script> <script src="map_data.p
<script src="http://maps.google.com/maps?file=api&v=2&key=mykey" type="text/javascript"></script>
<script src="map_data.php" type="text/javascript"></script>
<script src="map_functions.js" type="text/javascript"></script>
然后我在header.phh中的body标记后面指定了一个div:
http://www.santini.se/prova/listOfPontersCh2/http://www.santini.se/prova/listOfPontersCh2/<div id="map" style="width: 350px; height: 350px; border: blue 4px dashed">whyyyy</div>
http://www.santini.se/prova/listOfPontersCh2/http://www.santini.se/prova/listOfPontersCh2/whyyyy
map_data.php和map_functions.js文件与header.php放在同一文件夹中
此代码在WordPress之外正常工作。你可以在这里看到:
为什么它不能在WordPress中工作
任何提示都会有帮助:-(
提前谢谢
问候
Marina我认为您的脚本链接不正确。scr属性中的URI必须与当前URL相关,而不是与PHP文件相关 如果你的主题是“prosumer”,这可能会解决这个问题:
<script src="http://www.santini.se/geotimes/wp-content/themes/prosumer/map_data.php" type="text/javascript"></script>
<script src="http://www.santini.se/geotimes/wp-content/themes/prosumer/map_functions.js" type="text/javascript"></script>
或者您可以通过编程方式(我更喜欢):
<script src="<?php bloginfo('template_directory'); ?>/map_data.php" type="text/javascript"></script>
<script src="<?php bloginfo('template_directory'); ?>/map_functions.js" type="text/javascript"></script>