Support

Account

Home Forums General Issues Making ACF fields searchable with Swiftype

Helping

Making ACF fields searchable with Swiftype

  • I used to use Search Everything to search WordPress sites, since it also searched the ACF fields. However, Search Everything is no longer being supported and they suggested their users use Swiftype instead. I was wondering if anyone had experience getting Swiftype to search ACF fields. Their documentation offered some additional function code, but I can’t get it to search my ACF fields. I have some custom fields called “question” and “answer.” If this is beyond your support capabilities, please let me know.

    function swiftype_document_builder_filter( $document, $post ) {
      $document['fields'][] = array( 'name' => 'question', 'type' => 'text', 'value' => get_post_meta( $post->ID, 'question' ) );
      $document['fields'][] = array( 'name' => 'answer', 'type' => 'text', 'value' => get_post_meta( $post->ID, 'answer' ) );
    
      return $document;
    }
    
    add_filter( 'swiftype_document_builder', 'swiftype_document_builder_filter', 8, 2 );
  • Hi @marindee

    Sorry, I wont be much help on this one as I am unfamiliare with th eplugin you have referenced.

    Your code looks promising. Have you debugged the $document variable before returning it? Perhaps the formatting is 100% correct for the search plugin to work?

    Thanks
    E

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Making ACF fields searchable with Swiftype’ is closed to new replies.