Last active
July 3, 2020 19:07
-
-
Save itsmereal/44a04064079ba5d4c02e236a83731642 to your computer and use it in GitHub Desktop.
Filter for using ACF Repeater Field on Meta Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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