1//Create WordPress Query with 'orderby' set to 'rand' (Random)
2$the_query = new WP_Query( array ( 'orderby' => 'rand', 'posts_per_page' => '1' ) );
3// output the random post
4while ( $the_query->have_posts() ) : $the_query->the_post();
5 echo '<li>';
6 the_title();
7 echo '</li>';
8endwhile;
9
10// Reset Post Data
11wp_reset_postdata();
12