Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

How do I handle repeater field ACF. #826

Open
JonesDM opened this issue Apr 2, 2019 · 0 comments
Open

How do I handle repeater field ACF. #826

JonesDM opened this issue Apr 2, 2019 · 0 comments

Comments

@JonesDM
Copy link

JonesDM commented Apr 2, 2019

I have a CPT with repeater field created with field type 'User'. I use this to tag a users to the articles.
When user performs search, CPT search is working fine, but does not check Meta field 'user' I created. I want to include this, ie search the users that has been tagged.

I have checked the documentation and found the following.
`function my_post_attributes( array $attributes, WP_Post $post ) {

if ( 'news' !== $post->post_type ) {
    // We only want to add an attribute for the 'speaker' post type.
    // Here the post isn't a 'speaker', so we return the attributes unaltered.
    return $attributes;
}

// Get the field value with the 'get_field' method and assign it to the attributes array.
// @see https://www.advancedcustomfields.com/resources/get_field/
$attributes['add_users'] = get_field( 'add_users', $post->ID );

// Always return the value we are filtering.
return $attributes;

}`

I have also renabled : Index name: posts_acf-field and Index name: posts_acf-field-group in algolia settings and indexed.

Btw I checked the account and found that this field has been added to, so I think this is related to not showing in results page and autocomplete.

//Make custom fields searchable //alter the settings of the posts_speakerindex because in thesearchable_postsindex not all posts have thebioattribute add_filter( 'algolia_posts_speaker_index_settings', 'my_posts_index_settings' ); function my_posts_index_settings( array $settings ) { // Make Algolia search into the 'bio' field when searching for results. // Using ordered instead of unordered would make words matching in the beginning of the attribute make the record score higher. $settings['attributesToIndex'][] = 'unordered(add_users)'; // Make Algolia return a pre-computed snippet of 50 chars as part of the result set. $settings['attributesToSnippet'][] = 'add_users:50'; return $settings; }
Can anyone help me how to include search for repeater field?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant