Support

Account

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);