Search page doesn’t recognise post_type=page

I found a solution in this answer here: https://stackoverflow.com/questions/63678063/wordpress-search-filtering-pages-and-posts

I customised the function as follows:

function page_search_filter( \WP_Query $query ) {
    if ( ! is_admin() ) {
        if ( $query->is_main_query() && $query->is_search() ) {
            if ( isset( $_GET['post_type'] ) && $_GET['post_type'] == 'page' ) {
                $query->set( 'post_type','page' );
            }
        }
    }
    return $query;
}
add_action( 'pre_get_posts', 'page_search_filter' );

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş