Browser: Chrome 110 OS: macOS / Windows / Linux / etc. URL: Link to a page that illustrates this issue Video: Short screen recording that illustrates this issue (free tool: jam.dev)
ACF Repeater that is set on an options page and a post_type, when running a query loop in the post of that post types it takes the acf repeater of the options page.
[Please describe this bug in as much detail as possible so we can replicate & debug this bug]
Yes, but is not the same, in my case is in the query loop (ACF Repeater) that gets the options field. Any way I can do some provisional fix? maybe with a filter or so?
I have been checking the code, and I found the line that may be is the problem.
provider-acf.php // line 1096
$locations = isset( $field['_bricks_locations'] ) ? $field['_bricks_locations'] : [];
// This field belongs to a Options page
if ( in_array( 'option', $locations ) ) {
return 'option';
}
In my case $locations, which I imagine that are the places where bricks or wordpress used this acf field, has [“post”, “option”], and post_id is the right post to retrieve the data, so giving priority to post has more sense in that case and probably in most of them. Any way, having a simple option in the builder like “source” and select from [“post”, “option”, “term”, “user”] would have a clear use of the data to retrieve.
I did that fix. Is not the best way since we are accessing the database two times.
$locations = isset( $field['_bricks_locations'] ) ? $field['_bricks_locations'] : [];
if ( in_array( 'post', $locations ) ) {
$field_exists = get_field_object($field["name"], $post_id);
if($field_exists ) return $post_id;
}
// This field belongs to a Options page
if ( in_array( 'option', $locations ) ) {
return 'option';
}