首页 > 解决方案 > 不允许在 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 并将函数放在一个类中?

标签: phpwordpress

解决方案


推荐阅读