Last active
February 15, 2021 18:16
-
-
Save danielbachhuber/32f08fef5ab4c55a6d69f7bf22dbd7c2 to your computer and use it in GitHub Desktop.
Revisions
-
danielbachhuber revised this gist
Feb 15, 2021 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ 'solr_build_document', function ( $doc, $post ) { // Only override for this page template. if ( 'template-page-builder.php' !== get_post_meta( $post->ID, '_wp_page_template', true ) ) { return $doc; } -
danielbachhuber created this gist
Feb 15, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <?php /** * Uses the custom fields as the document's 'post_content'. */ add_action( 'solr_build_document', function ( $doc, $post ) { if ( 'template-page-builder.php' !== get_post_meta( $post->ID, '_wp_page_template', true ) ) { return $doc; } $plugin_s4wp_settings = solr_options(); $index_custom_fields = apply_filters( 'solr_index_custom_fields', $plugin_s4wp_settings['s4wp_index_custom_fields'] ); $post_content = ''; foreach ( $index_custom_fields as $meta_key ) { $post_content .= get_post_meta( $post->ID, $meta_key, true ) . PHP_EOL . PHP_EOL; } $doc->setField( 'post_content', strip_tags( $post_content ) ); return $doc; }, 10, 2 );