Home › Forums › Front-end Issues › User Field – display relationship posts. › Reply To: User Field – display relationship posts.
You would have to alter the query by adding a meta_query for the user field.
$meta_query = array(
array(
'key' => 'user_field_name',
// user field is stored as a serialized array
// of string User IDs
// value must be enclosed in quotes
// compare must be LIKE
'value' => '"'.$user_id.'"',
'compare' => 'LIKE'
)
);
$query->set('meta_query', $meta_query);
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.