$wpdb->insert() 给出错误未定义函数 [英] $wpdb->insert() is giving error undefined function
本文介绍了$wpdb->insert() 给出错误未定义函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 wp-content/theme/mytheme 文件夹中创建了一个新文件.
I have created a new file inside wp-content/theme/mytheme folder.
在文件里面我写了一个简单的查询
Inside the file I have written simple query
global $wpdb;
$insert= $wpdb->insert('wp_test', array(
'orderID' =>$_GET['orderID'],'amount'=>$_GET['amount'],'acceptance'=>$_GET['ACCEPTANCE'],'status'=>$_GET['STATUS'],
));
我收到错误调用未定义的函数".我必须在这个文件中包含文件吗?
I am getting error "Call to undefined function". Do I have to include file inside this file?
推荐答案
试试这个:在文件开头包含 wp-load.php.
Try this : include wp-load.php at beginning of file.
文件位于主题文件夹.
require_once('../../../wp-load.php'); //<-----please include this
global $wpdb;
$insert= $wpdb->insert('wp_test', array(
'orderID' =>$_GET['orderID'],'amount'=>$_GET['amount'],'acceptance'=>$_GET['ACCEPTANCE'],'status'=>$_GET['STATUS'],
));
这篇关于$wpdb->insert() 给出错误未定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文