Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

随机分类文章

// WP_Query arguments
$args = array(
	'post_type'              => array( 'post' ),
	'ignore_sticky_posts'    => true,
	'orderby'                => 'rand',
	'tax_query'              => array(
		array(
			'terms'            => array( '1', '2', '3' ),
		),
	),
);

// The Query
$查询 = new WP_Query( $args );

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

// Restore original Post Data
wp_reset_postdata();