By default, only the “full_text_search_search_text” field is searched. The value of the text field named “full_text_search_search_text” in ACF is searched.
Other fields must be customized with PHP code.
@ishitaka Thank you for your time replying. For the other fields – Can be done with PHP code..Do we have to use a hook from this plugin? Can you please give me an example. Is it capable of searching as well inside ACF File field? Thanks!
The code below will allow the ACF fields (my_text and my_file) to be searched.
add_filter( 'full_text_search_index_post', function( $data, $post_ID ) {
global $full_text_search;
if ( $full_text_search ) {
if ( 'post' === $data['post_type'] ) {
if ( function_exists( 'get_field' ) ) {
$keywords = $data['keywords'];
// Text
$my_text = get_field( 'my_text', $post_ID );
if ( $my_text ) {
$keywords .= "\n" . $my_text;
}
// PDF file (File ID)
$my_file_id = get_field( 'my_file_id', $post_ID );
if ( $my_file_id ) {
$keywords .= "\n" . get_post_meta( $my_file_id, 'full_text_search_search_text', true );
}
$data['keywords'] = trim( $keywords );
}
}
}
return $data;
}, 10, 2 );
* The full_text_search_index_post filter hook has been added since version 2.6.0.
Place this code in your child theme’s functions.php and regenerate your index.
We haven’t heard back from you in a while. I’ve gone ahead and marked this thread as resolved.
If the problem is not solved yet, please open a new thread.
Thanks!