With below code working for searching with post title and post content. And also after installing plugin 'ACF: Better Search', the post is also searching from the ACF fields and give search result on search result div element.
But now I also want to search the post with Author Name and with other custom added author meta values.
[WordPress 4.9.2]
Tried 'WP Extended Search — WordPress Plugins' plugin but did not worked.
// ajax hook for searching custom post type
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');
echo '<pre>';
//print_r($wp_query);
echo '</pre>';
endwhile;
wp_die();
}
Please could you help me. It will be better without using plugin.
Thanks