Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Basic Query

Query 12 random post

// WP_Query arguments
$args = array (
	'post_type'              => array( 'post' ),
	'posts_per_page'         => '12',
	'ignore_sticky_posts'    => true,
	'order'                  => 'ASC',
	'orderby'                => 'rand',
);

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

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

// Restore original Post Data
wp_reset_postdata();