如何在php中为wordpress API设置模板路径
How to set template path within php include for wordpress API
我有以下内容需要填写,但就我的一生而言,我无法通过读取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');
相关文章:
- Javascript:使用绝对路径设置img src
- 如何设置SVG路径的样式以拍摄图像
- Soundmanager 2,无论我尝试什么,我都无法设置SWF路径
- 如何根据两个不同的输入动态设置链接的路径
- Angular sqlLite set css url()无法设置相对路径
- 迪吉特.树设置路径并滚动到所选节点
- 如何在目录中设置路径“/”指向索引.html的简单静态服务器
- 使用RaphaelJS将路径缩放为纸张大小或以像素为单位设置路径尺寸
- 我正在尝试设置cookie及其路径,但无法正确设置路径
- Javascript cookie.未设置路径
- 在node.js中为require设置路径
- 如何在JavaScript中保存cookie值时设置路径?
- 在下载对话框中设置路径目录
- 在javascript文件上设置路径
- RequireJS:设置路径为'ignore'
- 直接设置路径中的每个点'画布上的alpha通道
- 在immutable.js setIn([])函数中动态设置路径
- Raphael JS:如何移动/设置路径对象的动画
- 如何使用snap.svg设置路径变形的动画
- 如何设置路径'提交'将上传的文件保存为'上传的照片'在AngularJS中