for search I am using this function
This is working fine on searching post with post title, post content and from ACF fields on post. but not from author.
add_action( ‘wp_ajax_search_cposttype’, ‘searchCposttypeByTerm’ );
add_action( ‘wp_ajax_nopriv_search_cposttype’, ‘searchCposttypeByTerm’ );
function searchCposttypeByTerm() {
//$authors=get_users();
$wp_query = new WP_Query(array(
‘post_type’=>’cposttype’,
‘post_status’=>’publish’,
‘s’ => $_GET[‘searchTerm’]));
while ($wp_query->have_posts()) : $wp_query->the_post();
get_template_part(‘template-parts/cposttype/cposttype-post’);
endwhile;
wp_die();
}