我有一个PHP脚本,需要作为cron作业运行。但是,此脚本需要访问WP API(get_pages()
, get_post_meta()
和get_permalink()
具体而言)。我已经按照http://codex.wordpress.org/Integrating_WordPress_with_Your_Website, 但无济于事。
代码:
require_once(\'../../../wp-blog-header.php\');
$args = array(
\'child_of\' => 2083
);
$pages = get_pages($args);
但是当我跑步的时候php -q this_file.php
我从命令行获得以下输出:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Database Error</title>
</head>
<body>
<h1>Error establishing a database connection</h1>
</body>
</html>
有人有什么想法/建议吗?