ACF: Indexing files from File fields
-
Good morning,
Relevanssi can index attachment contents from files linked to posts with ACF File fields. This does not happen automatically but requires some extra code.
For “File Array”:
add_filter( 'relevanssi_content_to_index', 'rlv_get_acf_file', 10, 2 ); add_filter( 'relevanssi_excerpt_content', 'rlv_get_acf_file', 10, 2 ); function rlv_get_acf_file( $content, $_post ) { $file = get_field( 'pdf_file', $_post->ID ); if ( is_array( $file ) && isset( $file['ID'] ) ) { $content .= ' ' . get_post_meta( $file['ID'], '_relevanssi_pdf_content', true ); } return $content; }
I add the code to my site and rebuild the index, but searching by pdf file name does not show any posts as a result.
I have Relevanssi free installed.
In this line I substituted ‘pdf_file’ by field name:
- get_field( ‘pdf_file’, $_post->ID );
Can you help me?
Thank you so much
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘ACF: Indexing files from File fields’ is closed to new replies.