Home Forums General Issues ACF Repeater fields and Relevanssi


ACF Repeater fields and Relevanssi

  • Hi,

    I would like to create custom excerpts for the search function.
    I use this code and this works for these fields:

    function custom_fields_to_excerpts($content, $post, $query) {
        $fields = get_field('inhoud', $post->ID);
    		foreach($fields as $field){
    			if ($field['acf_fc_layout'] == "2_kolommen_tekst_afbeelding-3_1-3"){
    				$content .= " " . $field['kolom1'];
    			} elseif ($field['acf_fc_layout'] == "2_kolommen_afbeelding_tekst"){
    				$content .= " " . $field['kolom2'];
        return $content;
    add_filter('relevanssi_excerpt_content', 'custom_fields_to_excerpts', 10, 3);

    I also have some repeater fields and I can’t get these to be included in the excerpt.

    The repeater fields are structured as follows:
    ‘inhoud’ (flexibele content) > ‘2_kolommen_repeater_container’ > ‘2_kolommen_repeater’ (repeater field) > ‘kolom1’ / ‘kolom2’

    So the last ones (‘kolom1’ and ‘kolom2’) are the fields with the actual content and need to be included in the excerpt.

    I tried some things with the suggestions mentioned here:

    Like this:

    	foreach($fields as $field){
    		$content .= " " . $field['2_kolommen_repeater_container'];

    This doesn’t work. I guess it has something to do with the repeater field itself doesn’t containing text. It needs to check a subfield of the repeater.

    Does anyone have a suggestion to get this working?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.