Skip to content

Instantly share code, notes, and snippets.

Avatar
🦆

Jason Murray Jason-Murray

🦆
View GitHub Profile
@Jason-Murray
Jason-Murray / functions.php
Last active Jun 28, 2019
Adds all "visible" custom fields to the custom search excerpt for Relevanssi, code is based on the indexing code used in Relevanssi to add these fields to the index.
View functions.php
// Relevanssi add content to custom excerpts.
add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);
function custom_fields_to_excerpts($content, $post, $query) {
$custom_fields = get_post_custom_keys($post->ID);
$remove_underscore_fields = true;
if (is_array($custom_fields)) {
$custom_fields = array_unique($custom_fields); // no reason to index duplicates
foreach ($custom_fields as $field) {
You can’t perform that action at this time.