Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WordPress、谷歌地图和;header.php中的JavaScript_Javascript_Wordpress_Google Maps - Fatal编程技术网

WordPress、谷歌地图和;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&amp;v=2&amp;key=mykey" type="text/javascript"></script> <script src="map_data.p

我想在WordPress网站(www.santini.se/geotimes)的入口页面上显示一个带有多个指针的谷歌地图。我在header.php的头部指定了以下Javascript代码:

 <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;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>