您需要将帖子类型指定为帖子-改为在$args中尝试以下操作:
$args = array(
\'post_type\' => \'post\', // Specifying you want posts only
\'posts_per_page\' => 1,
\'orderby\' => \'rand\',
\'post_status\' => \'publish\',
);
最重要的是,您需要将$args应用于查询,因此请对循环执行以下操作:
while ( $the_query->have_posts() ) : $the_query->the_post();
请参见
this in the Codex.