Support

Account

Home Forums Add-ons Repeater Field Searchable Repeater Fields ?

Solving

Searchable Repeater Fields ?

  • I have search high and low for a way to make the default WordPress search include custom fields.

    It was a long and arduous quest, let me tell you.

    I was able to use a bit of code that someone put up on github (custom-search-acf-wordpress) and have it successfully returned matches for my ACF repeater fields. However, it took well over a minute to load the search result page which is unacceptable. (I also had the exact same thing happen with the use of the Relevanssi plugin – matches to ACF repeater fields were picked up, but again it took forever to load.)

    This data NEEDS to be searchable, so I’ve currently given up on using the repeater field for that particular data because of this. (I was able to include non-repeater custom fields in the default WP search at regular speed – if you want the code feel free to ask.)

    Can anyone tell me if/how it would be possible to include the repeater fields in the search while keeping the load time at a decent speed?

    • Elliot

    • October 31, 2013 at 3:56 pm

    Hi @kisabelle

    Currently, we have not found a way to search repeater field data with fast speeds. This is due to the way in which WP saves data and the way in which ACF saves the repeater field data.

    Perhaps you could think about caching the search results or using a transient to temp save the data?

    Perhaps you could explain what your data setup is and what the search functionality needs to do.

    Thanks
    E

  • Hi @elliot

    My project is a blog where they will periodically be posting featured weddings. It is a custom with these types of blogs that they will have a list of acknowledgements at the bottom of the post that tells the reader where they got the cake, the flower arrangements and things like that.

    I thought the repeater field would be perfect since the size and contents of the list could differ greatly from post to post.

    Since this can still be easily input via a custom field with a WYSIWYG editor, it’s not worth the time/trouble to figure out how to make the repeater fields searchable for me at this time.

    I -am- still using the repeater field for these same blog posts so that the blogger can create a photo gallery (though in hindsight my client would’ve been better off if I went with the Gallery plugin for this project instead).

    Once I found out the way that repeater fields are stored in the database, mycustomfield_0_mysubfield, mycustomfield_1_mysubfield, and soforth, I thought if I could somehow return a list of those meta_keys so that I could put them in my array of custom fields it might work…

    eg. $custom_fields = array(‘mycustomfield_0_mysubfield’, ‘mycustomfield_1_mysubfield’);

    But it would differ depending on the post… so I’m not sure if that would work. Here is my code: pastebin

    • Elliot

    • November 3, 2013 at 7:00 pm

    Hi @kisabelle

    Perhaps you missed it, but there is a much nicer way to code this and is explained on the docs page here:
    http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/

    Thanks
    E

  • Hi @elliot

    Thanks. I had seen that. I tried integrating it into the code that I have working but I’m not experienced enough with mySQL and PDO and I’m at a loss of how to go about it.

    • Elliot

    • November 5, 2013 at 3:07 pm

    Hi @kisabelle

    Just let me know if there’s anything I can help you with. Maybe there are some specifics to the tutorial which you don’t understand?

    Thanks
    E

Viewing 6 posts - 1 through 6 (of 6 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.