使用API函数时,更容易看到WordPress查询的确切内容,而不是从头开始构造查询:
get_posts(array(
\'numberposts\' => -1,
));
var_dump( $wpdb->last_query );
提供以下SQL:
SELECT wp_posts.* FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = \'post\'
AND (wp_posts.post_status = \'publish\')
ORDER BY wp_posts.post_date DESC