query – Querying Posts from ACF Repeater Subfield Select Value
Question
I am attempting to query posts based on the value of a repeater subfield dropdown (select field) but am having trouble.
Here is what I am working with:
<?php
// Set up the arguments for the query
$args = array(
'meta_query' => array(
array(
'key' => 'groups_and_committees_selector_$_committees_groups', // name of the ACF subfield
'value' => 'Board of Directors', // value to filter by
'compare' => '=' // comparison operator
)
)
);
$user_query = new WP_User_Query($args); // Create the WP_User_Query object
$users = $user_query->get_results();// Get the results
foreach ( $users as $user ) { // Loop through the users
echo 'User Name: ' . $user->user_firstname . '<br>'; // Display the user's login name
}
?>
This is not returning any results. If I try the above code but use a standard field key of “test” and value of “true” it returns the two users I setup for that test correctly.
I am guessing there is an issue with my key or my value but I cannot figure it out.
What am I doing wrong in my code?
0
4 weeks
2023-01-08T18:21:46-05:00
2023-01-08T18:21:46-05:00 0 Answers
0 views
0
Leave an answer