Last active
February 15, 2021 18:16
-
-
Save danielbachhuber/32f08fef5ab4c55a6d69f7bf22dbd7c2 to your computer and use it in GitHub Desktop.
This file contains 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 characters
<?php | |
/** | |
* Uses the custom fields as the document's 'post_content'. | |
*/ | |
add_action( | |
'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; | |
} | |
$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 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment