Support

Account

Home Forums Add-ons Repeater Field How to perform a meta query on an ACF repeater row's field data?

Solved

How to perform a meta query on an ACF repeater row's field data?

  • I’m trying to perform a meta query on an ACF repeater field but I’m unsure how to go about it. I have an “Additional Details” repeater field where the user can add custom details about a property. The two columns in the repeater field are “Name” and “Value”. A user could, for example, add a new row with the name “Available”, and value “Now”.

    I’d now like to perform a meta query based on one of the name fields, for example, ensuring that “Available” is set to “Now”.

    The repeater field key is cf47rs_additional_details, so it has a pattern like cf47rs_additional_details_0_name, for each row.

    I need to find the row in which name = ‘Available’ and query for that value somehow. I’ve seen this type of meta query pattern but I’m unsure if this is what I need:

    'meta_query' => [
        [
            'key' => 'cf47rs_additional_details_%_name',
            'value' => 'Now'
        ]
    ]
  • Based on this answer from John Huebner: https://support.advancedcustomfields.com/forums/topic/query-repeater-field-with-two-values/, I determined that this wasn’t possible.

    So, I went the route of hooking in with a filter on acf/save_post to add a query-able post meta key based on the repeater field data, as detailed here: https://support.advancedcustomfields.com/forums/topic/sorting-admin-column-with-repeater/

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

You must be logged in to reply to this topic.