Problems Indexing ACF Fields
-
Hi,
I have lots of information on my site being displayed using ACF fields. I’ve followed the post here but seem to be missing something, as even after indexing and pushing the changes they’re not being indexed/shown in search results.
They are being used on a Custom Post Type, which is showing results in my search, but only looking at their name and excerpt to check content, but not my ACF fields.
What I’ve been working with is below, but I’m guessing I’m applying it wrong or not understanding something.
Any help appreciated – thanks
function wds_algolia_custom_fields( array $attributes, WP_Post $post ) { // Eligible post meta fields. $fields = [ 'short_bio', 'practice_areas', 'qualifications', 'experience', ]; // Loop over each field... foreach ( $fields as $field ) { // Standard WordPress Post Meta. $data = get_post_meta( $post->ID, $field ); // Advanced Custom Fields. $data = get_field( $field, $post->ID ); // Only index when a field has content. if ( ! empty( $data ) ) { $attributes[ $field ] = $data; } } return $attributes; } add_filter( 'algolia_post_shared_attributes', 'wds_algolia_custom_fields', 10, 2 ); add_filter( 'algolia_searchable_post_shared_attributes', 'wds_algolia_custom_fields', 10, 2 );
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Problems Indexing ACF Fields’ is closed to new replies.