如何在php include for wordpress API中设置模板路径
我需要填写以下内容,但我一生都无法阅读如何在php include for wordpress API中设置模板路径,php,javascript,jquery,Php,Javascript,Jquery,我需要填写以下内容,但我一生都无法阅读get_template_directory_uri()以便正确包含文件。这将导致在运行此脚本之前加载页面,但随后会破坏所有内容(空白) 我已经包括了循环结束/重启点,以防出现wordpress问题 <?php endwhile; ?> <?php wp_reset_postdata(); ?> </div> </div> &l
get_template_directory_uri()代码>以便正确包含文件。这将导致在运行此脚本之前加载页面,但随后会破坏所有内容(空白)
我已经包括了循环结束/重启点,以防出现wordpress问题
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
<div id="firstpost" class="topfirstpost">
<?php
include ( get_template_directory_uri().'/lib/forecast.io.php');
$api_key = '<tempkey>';
$latitude = '49.261226';
$longitude = '-123.113927';
$forecast = new ForecastIO($api_key);
/*
* GET CURRENT CONDITIONS
*/
$condition = $forecast->getCurrentConditions($latitude, $longitude);
echo $condition->getTemperature();
?>
</div>
<div id="secondpost" class="topsecondpost">
<?php
$first_query = new WP_Query('cat=2&showposts=1&offset=2');
while($first_query->have_posts()) : $first_query->the_post();
?>
如果有人想知道的话,这是forecast.io api的一个片段。您尝试过添加/
include( get_template_directory_uri().'/lib/forecast.io.php');
我想可能是get_template_directory_uri()返回一个http方向,而某些版本的php不支持远程文件访问,我只会尝试这样使用它
include('lib/forecast.io.php');
是的,我试过了。仍然会导致此后的一切变黑。不幸的是,这也不起作用,所以我只能相信这个web API已经崩溃了。。。无论如何,谢谢你。如果更多答案证明有效,将更新此问题。