Divi Blog Module – How to Order Randomly

Sort Posts In Random Order from a specific Divi Blog module!
  • Assign this CSS ID to your Blog module:
random_posts
function dd_random_posts($query, $args) {
	if (isset($args['module_id']) && $args['module_id'] === 'random-posts') {
		$query->query_vars['orderby'] = 'rand';
		$query->query_vars['order'] = 'ASC';
		$query = new WP_Query( $query->query_vars );
	}
	return $query;
}
add_filter('et_builder_blog_query', 'dd_random_posts', 10, 2);

👉 Subscribe to our YouTube channel

More Videos