• Resolved Alberto

    (@albert0deavila)


    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.

    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 added the code to your site and rebuilt the index. But I get no results when searching for a pdf file of a post.

    Can you help me?
    Thank you so much

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘ACF: Indexing files from File fields’ is closed to new replies.