Indexing ACF Sub fields
-
Hi,
This is a follow-up to this post, which solved the initial issue.
So i’m currently using the below code to index all my
the_fieldinstances in ACF I want, which works fine.I have a builder in ACF, which has
the_fieldofcontent_page_builderand inside has severalthe_sub_fieldwhich I can’t get to index. Is there a way to get these sub fields to index? I guess it will be slightly different in theforeachperhaps? (simply because it mentions$data = get_field( $field, $post->ID );.function my_post_attributes( array $attributes, WP_Post $post ) { $fields = [ 'short_introduction', 'practice_areas', 'qualifications', 'skills_experience', 'awards', 'memberships', 'hero_image', 'hero_text', 'content_page_builder', //the_field 'text_block', // the_sub_field - not indexing 'narrow_text_block', // the_sub_field - not indexing 'alternating_call_to_actions', // the_sub_field - not indexing ]; $ourdata = []; foreach ( $fields as $field ) { $data = get_field( $field, $post->ID ); if ( ! empty( $data ) ) { $ourdata[] = $data; } } // Get the field value with the 'get_field' method and assign it to the attributes array. $attributes['acf_fields'] = $ourdata; return $attributes; } add_filter( 'algolia_post_shared_attributes', 'my_post_attributes', 10, 2 ); add_filter( 'algolia_searchable_post_shared_attributes', 'my_post_attributes', 10, 2 ); /** * @param array $settings * * @return array */ function my_posts_index_settings( array $settings ) { $settings['searchableAttributes'][] = 'unordered(acf_fields)'; return $settings; } add_filter( 'algolia_posts_index_settings', 'my_posts_index_settings' );Many thanks!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Indexing ACF Sub fields’ is closed to new replies.