Skip to main contentSkip to footer

On sites where ACF fields are used a lot, with Flexible Content and Repeater fields, it may be difficult to make Relevanssi only index the relevant ACF fields.

One way to deal with problem is to set Relevanssi to index “visible” custom fields and then restrict the indexed fields by field type. Add this function to your site to restrict the custom field indexing to only “text” type fields:

add_filter( 'relevanssi_index_custom_fields', function( $fields ) {
    $indexed_fields = array();
    foreach( $fields as $field ) {
        $object = get_field_object( $field );
        if ( is_array( $object ) && isset( $object['type'] ) && 'text' === $object['type'] ) {
            $indexed_fields[] = $field;
        }
    }
    return $indexed_fields;
} );

To control which field types are included, modify the “if” clause to include more field types.

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Flatsome

…for posts and pages. If the live search does not work Flatsome has a built-in live search that should work with Relevanssi without modifications, but in case it doesn’t (for example searching for partial SKUs doesn’t work correctly even though it works in the Relevanssi admin search), you can add……post objects. */ function rlv_flatsome_search_function( $query, $args, $defaults ) { $args[‘relevanssi’] = true; return get_posts( $args ); } add_filter( ‘flatsome_ajax_search_function’, function() { return ‘rlv_flatsome_search_function’; } ); Improving live search with product variations If you want the live search to take the searcher directly to the right variation, here’s what you……this to your site: /** * Replaces the Flatsome live search default function (get_posts()) with Relevanssi. * * @param string $query The search query, not used. * @param array $args The search query arguments. * @param array $defaults The default values, not used. * * @return array An array of…

Search results in random order
Do you want to order your search results in random order? Here’s how: add_filter( 'relevanssi_hits_filter', 'shuffle_search' ); function shuffle_search( $hits…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed