Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Query Batch Random 1

// WP_Query arguments
$args = array(
	'post_type'              => array( 'bonmot' ),
	'nopaging'               => true,
	'posts_per_page'         => '1',
	'orderby'                => 'rand',
);

// The Query
$query_batch_random = new WP_Query( $args );

// The Loop
if ( $query_batch_random->have_posts() ) {
	while ( $query_batch_random->have_posts() ) {
		$query_batch_random->the_post();
		// do something
	}
} else {
	// no posts found
}

// Restore original Post Data
wp_reset_postdata();