2011-09-09 39 views
0

我想在WordPress网站(www.santini.se/geotimes)的入口页面中显示带有多个指针的GoogleMap。我指定的header.php头中下面的JavaScript代码:header.php中的WordPress,GoogleMaps和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> 

然后我指定一个div只是header.phh body标签后:

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> 

的文件map_data.php和map_functions .js放在与header.php相同的文件夹中。

此代码在WordPress之外正常工作。你可以在这里看到它:http://www.santini.se/prova/listOfPontersCh2/

为什么它不工作在WordPress?

任何暗示将有助于:-(提前

感谢

问候

滨海

回答

1

我想你的脚本没有正确的联系。这个URI的SCR-属性必须相对于当前的URL,而不是PHP文件。

如果你的主题是'消费者',这可能会解决它:

<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> 
+0

它的工作原理!感谢罗布:-))) –

+0

不客气! ;) –

相关问题