Home › Forums › ACF PRO › Relationship Field (Post Object) filtering › Reply To: Relationship Field (Post Object) filtering
I’m actually trying to do the same thing and having the same problem where no results show up. Did you end up figuring this out? Not sure what I’m doing wrong.
as you can see. I’ve tried a few different ways and none seem to work. the field is set to show “documents” post type and I’m trying to filter by the documents custom field “rfi_project” and if it matches the current project.
// filter RFI Drawing Reference for only this project
function tmc_rfi_drawings_for_project( $args, $field, $post_id ) {
$meta_query = array();
$meta_query[] = array(
'key' => 'rfi_project',
'value' => get_the_ID()
);
$args['meta_query'] = $meta_query;
//$args['meta_key'] = "rfi_project";
//$args['meta_value'] = $post_id;
return $args;
}
add_filter('acf/fields/post_object/query/key=field_59d435129094f', 'tmc_rfi_drawings_for_project', 10, 3);
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.