我为导出CSV创建了一个单独的PHP脚本。单击该按钮时,它将指向表单操作,其中我的PHP脚本是链接。为什么当我使用$ wpdb函数时它会“null”?
致命错误:在C:\ xampp \ htdocs \ pwhs.ph \ wp-content \ themes \ pwhs \ simple-user-listing \ export-csv.php中调用null上的成员函数get_results()第8行
<?php
global $wpdb;
if(isset($_POST['exportBtn'])){
ob_end_clean();
$result = $wpdb->get_results("SELECT name FROM wp_diocese");
答案 0 :(得分:0)
$path = $_SERVER['DOCUMENT_ROOT'];
include_once $path . '/wp-config.php';
include_once $path . '/wp-load.php';
include_once $path . '/wp-includes/wp-db.php';
include_once $path . '/wp-includes/pluggable.php';
if(isset($_POST['exportBtn'])){
global $wpdb;
刚刚收录了Wordpress标题。由@u_mulder提醒