感谢Tom J Nowell指点我使用WP_Query
而不是get_posts
. 通过WP\\U查询,您可以WP_Query
要引用的对象。下面给出了我使用的参数的实际mysql查询。
// these same args also worked with get_posts()
$args = array(
\'post_type\' => \'post\',
\'order\' => \'ASC\',
\'post_status\' => \'publish\',
);
// create a new WP_Query object with the args above
$the_object = new WP_Query($args);
// show the mysql as a string
echo $the_object->request;
// see EVERYTHING in the WP_Query object
var_dump($the_object);