Home › Forums › ACF PRO › Reverse query on author.php from User Relationship field › Reply To: Reverse query on author.php from User Relationship field
That’s weird. Your code looks OK for me. Could you please try to add the ID manually and change the compare option? You can try the following codes:
$items = get_posts(array(
'post_type' => 'attorney',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'vbmmp_attorney_related_user_profile', // name of custom field
'value' => '"123"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
));
$items = get_posts(array(
'post_type' => 'attorney',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'vbmmp_attorney_related_user_profile', // name of custom field
'value' => '123', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => '='
)
)
));
$items = get_posts(array(
'post_type' => 'attorney',
'posts_per_page' => -1,
'meta_key' => 'vbmmp_attorney_related_user_profile',
'meta_value' => '123',
'meta_compare' => '=',
));
You can also try to get the post based on another custom field to check it up. To learn more about the custom field query, please take a look at this page: https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters.
I hope this helps.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.