Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?

If Search and Filter Pro doesn’t help with this out of the box, it will take more effort to achieve this.

What I would do:

Move query to a separate function that would stay in functions.php file. It would return query results (example bellow).

function theme_prefix_return_professionals($type="professionals", $fid = '204') {

    $letter="";

    $post_type = $type;
    $filter_id = $fid;

    $args = array( 
        'post_type' => $post_type,
        'post_status' => 'publish',
        'search_filter_id'  => $filter_id
    );



    $query = new WP_Query($args);

    return $query;

}

Hook this function in ajax_priv and ajax_no_priv.

Have a jQuery function to trigger on letters click and pass letter the function (function would need to be extended for that, also use some best practices as nonce checking and so on).

Once action is triggered with the help of jQuery, we add new parameter to $args, so function would extend to something like that:

function theme_prefix_return_professionals($type="professionals", $fid = '204') {

    $letter="";

    $post_type = $type;
    $filter_id = $fid;

    $args = array( 
        'post_type' => $post_type,
        'post_status' => 'publish',
        'search_filter_id'  => $filter_id
    );


    if ($_POST['letter']) {

        $letterVal="^" . $_POST['letter'];

        $args['meta_query'][] = array(
            'key'       => 'proffesional_surename',
            'value'     => $letterVal,
            'compare'   => 'REGEXP',
        );
    }


    $query = new WP_Query($args);

    return $query;

}

Then we update the div with returned query data (most likely returned as JSON).

There’s a lot more to this, like security concerns (escaping values, adding and checking for nonce, returning JSON) but this would require me to solve the issue for you and spend a good hour on it.

Hopefully I helped you enough to figure this out on your own and it should give you an idea of how to approach this.