How to get Relevanssi to index the contents of a DFlip Flipbook

[ad_1]

I added DearFlip to the list. Here’s the code for it:

add_filter( 'relevanssi_content_to_index', 'rlv_dearflip_content', 10, 2 );
function rlv_dearflip_content( $content, $post ) {
$m = preg_match_all( '/\[dflip.*?id=["\'](.*?)["\']/', $post->post_content, $matches );
if ( $m ) {
global $wpdb;
$upload_dir = wp_upload_dir();
foreach ( $matches[1] as $flipbook_id ) {
$data = get_post_meta( $flipbook_id, '_dflip_data', true );
$pdf_url = ltrim( str_replace( $upload_dir['baseurl'], '', urldecode( $data['pdf_source'] ) ), '/' );
$pdf_content = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_relevanssi_pdf_content' AND post_id IN ( SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s )", $pdf_url ) );
$content .= $pdf_content;
}
}
return $content;
}

However, this doesn’t work in the free version of Relevanssi because you need Relevanssi Premium to index the PDF contents.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer