Created
May 6, 2020 17:09
-
-
Save mujahidi/ea94ad8b309f5f8c828d949c0df37c72 to your computer and use it in GitHub Desktop.
Querying posts by ACF User field type
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 | |
$search_value = 'xyz'; // whatever | |
$field_value = sprintf( '^%1$s$|s:%2$u:"%1$s";', $search_value, strlen( $search_value ) ); | |
$args = array( | |
'post_type' => 'post', | |
'meta_query' => array( | |
array( | |
'key' => 'user_field', | |
'value' => $field_value, | |
'compare' => 'REGEXP' | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment