Support

Account

Home Forums General Issues Making ACF fields searchable with Swiftype

Helping

Making ACF fields searchable with Swiftype

    • marindee

    • September 24, 2013 at 9:19 am

    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 );
    • Elliot

    • September 24, 2013 at 1:27 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.