您可以改为执行外部查询。
<?php
define(\'WP_USE_THEMES\', false);
global $wpdb;
require(ROOT_DIR.\'/blog/wp-load.php\');
query_posts(\'showposts=1\');
get_header();
try{
$args = array(\'post_type\' => array(\'post\'), \'posts_per_page\' => -1);
$qry = null;
$qry = new WP_Query($args);
if($qry->have_posts()){
while($qry->have_posts()){
$qry->the_post();
$theTitle = get_the_title();
print $theTitle.\'<br>\';
}
wp_reset_query();
}else{
print \'no records found\';
}
}catch(Exception $e){
print $e->getMessage();
}
get_footer();
?>