Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

Reply To: Display grid of posts randomly

Home Forums Support Display grid of posts randomly Reply To: Display grid of posts randomly

#187241
Ryan

I found something better:

function my_random_posts_order( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'orderby', 'rand' );
    }
}
add_action( 'pre_get_posts', 'my_random_posts_order' );

I could not manage to get the code working in GP Hooks so I added it to my child functions.php file.