2
我試圖在wordpress以外的腳本上使用wordpress函數和$wbdb
,但我無法弄清楚如何去做。通過擴展類來在其外部使用wordpress 4.0?
我想:
require_once('./wp-load.php'); // this is the correct path is tested.
class cron extends wpdb {
public function results(){
$sql = 'SELECT sub_id,email,cate_id FROM co_subsriber WHERE status = 0 ORDER BY sub_id ASC LIMIT '.$start.',750'; // $start =0
$records = $wpdb->get_results($sql);
}
}
我得到錯誤
Warning: Missing argument 1 for wpdb::__construct(), called in wp-db.php on line 578
Warning: Missing argument 2 for wpdb::__construct() called in wp-db.php on line 578
Warning: Missing argument 3 for wpdb::__construct() called in wp-db.php on line 578
Warning: Missing argument 4 for wpdb::__construct() called in wp-db.php on line 578
Notice: Undefined variable: dbuser wp-db.php on line 602 and all other pass, hostname...
無法選擇數據庫....
我需要一提的是與
require_once('./wp-load.php');
並使用簡單的PHP,沒有面向對象它的工作正常。
那麼我應該擴展哪個類?
在這裏閱讀http://codex.wordpress.org/Integrating_WordPress_with_Your_Website – Napolux 2014-10-11 08:35:21
爲什麼你想擴展類呢?只需將它存儲在構造函數的類中並使用它。 – 2014-10-11 08:36:38
@Napolux添加了'require('./ wp-blog-header.php');'同樣的錯誤。此外,它並沒有說明如何在你創建的課程中做到這一點。 – user3467855 2014-10-11 08:37:09