我有一个插件文件夹foobar。
在这个插件中,我有一个名为foobar的页面。php。在这页里我有
global $wpdb;
$orderby = (!empty($_REQUEST[\'orderby\'])) ? $_REQUEST[\'orderby\'] : \'name\'; //If no sort, default to title
$sql = "SELECT * FROM wp_nc_location ORDER BY " . $orderby;
$data = $wpdb->get_results($sql);
此查询在我的foobar中工作。php页面。然而,在同一个文件夹中,我有另一个名为process的页面。php,当我包含相同的代码时:global $wpdb;
$orderby = (!empty($_REQUEST[\'orderby\'])) ? $_REQUEST[\'orderby\'] : \'name\'; //If no sort, default to title
$sql = "SELECT * FROM wp_nc_location ORDER BY " . $orderby;
$data = $wpdb->get_results($sql);
我收到错误消息:Fatal error: Call to a member function get_results() on a non-object in...
为什么全局$wpdb在另一个页面中似乎不起作用?(process.php)?