Randomize listings order and pages

Found the solution, trying now to do the same with the search results, will update if succeeded.

// Initialize session if not already started
if (!session_id()) {
    session_start();
}

add_filter( 
    'posts_orderby', 
    function($orderby, $query){
        if ( $query->get( 'post_type' ) === 'hp_listing' && is_post_type_archive('hp_listing') && empty($_GET['_sort']) ) {
            if (isset($_SESSION['listing_seed'])) {
                $seed = $_SESSION['listing_seed'];
            } else {
                $seed = time(); // Use the current timestamp as the seed
                $_SESSION['listing_seed'] = $seed;
            }
            $orderby = "RAND($seed)";
        }

        return $orderby;
    }, 
    10, 
    2 
);

Just a short explanation about the code: it will randomize the order for the session, this way it will not show the same listings on other pages and the next time visiting the site it will randomize again.