php - 不允许在 wordpress 插件的其他函数中调用函数?
问题描述
我很难让这个小插件运行。
function latest_price(){
global $wpdb;
$result = $wpdb->get_results("SELECT bid,ask FROM wp_ticker ORDER BY indate DESC limit 1");
$price = $result[0]->bid;
return $price;
}
function outputprice(){
$output = $this->latest_price();
echo $output;
}
add_shortcode ('getprice', 'outputprice');
当我尝试在 wordpress 页面上运行此简码时,页面不会加载。当我打开调试时,我没有看到任何错误?这种结构是允许的还是我应该使用 OOP 并将函数放在一个类中?
解决方案
推荐阅读
- azure - LUIS 列表实体
- javascript - React Native:使用 UI 工具包进行设计好不好?
- firebase - Firebase 云功能节点 8 引擎修复
- unity3d - Unity3D:当我选择输入文件和输入字段仍然焦点时如何隐藏触摸屏键盘
- java - 使用 Java JDBC 连接从 Unix 服务器进行 MSSQL 数据库 LDAP/Windows 身份验证
- php - WordPress 的自定义[列] 可排序钩子如何工作?
- c - C解析具有相同名称的json对象
- python - 如何使用python中的循环在数据框中创建一个新列
- javascript - AngularJS选择选定属性的索引
- android - 在不使用 github 存储库的情况下创建库