Elementor Posts Query: Random Order
Adds a custom query ID "wpide_random" that shows posts in random order in Elementor Pro's Posts and Loop Grid widgets, for testimonials, team members or featured products.
Opens WPIDE on
Code
add_action( 'elementor/query/wpide_random', function ( $query ) {
$query->set( 'orderby', 'rand' );
$query->set( 'ignore_sticky_posts', true );
$query->set( 'no_found_rows', true );
} );
Notes
Type wpide_random in the Query ID field. Page caching will freeze the order until the cache is cleared.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.