Skip to content

Instantly share code, notes, and snippets.

@itsmereal
Last active July 3, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsmereal/44a04064079ba5d4c02e236a83731642 to your computer and use it in GitHub Desktop.
Save itsmereal/44a04064079ba5d4c02e236a83731642 to your computer and use it in GitHub Desktop.
Filter for using ACF Repeater Field on Meta Query
<?php
/**
* Filter ACF Meta so repeater fields can be used in meta_query
* Here 'repeater_field' is the repeater field name
*/
function cts_filter_acf_meta( $where ) {
$where = str_replace( "meta_key = 'repeater_field_$", "meta_key LIKE 'repeater_field_%", $where);
return $where;
}
$args[ 'meta_query' ] = array(
array(
'key' => 'repeater_field_$_repeater_sub_field', // Format: repeater_field + _ + $ + _ + repeater_sub_field
'value' => true,
'compare' => '='
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment