I would like to query an ACF repeater field. I've a repeater field called Library (in a CPT called Book) and, in this repeater, I have a relation field called Library (that is connected to an other custom post type called Library). It is this field that I would like to query*.
I look to recover, thanks to an unique value given by the user (selected thanks to a select), all the books that are in relation with this Library.
Ex : 'Library 1' is selected. Return : 'Harry Potter 1' and 'Harry Potter 2'.
Trials (not working)
function my_posts_where( $where ) {
$where = str_replace("meta_key = 'library_$", "meta_key LIKE 'library_%", $where);
return $where; } add_filter('posts_where', 'my_posts_where');
$library= $_GET['library'];
$v_args = array(
'post_type' => 'book',
'meta_query' => array(
array(
'key' => 'library_$_library',
'compare' => '=',
'value' => $library,
),
)
); $Query = new WP_Query($v_args);
if($Query->have_posts()) :
while($Query->have_posts()) : $Query->the_post();
...
endwhile;
else :
...
endif;
And this
$library= $_GET['library'];
$v_args = array(
'post_type' => 'book',
'meta_query' => array(
array(
'key' => 'library',
'value' => $library,
'compare' => 'LIKE',
),
)
);
$Query = new WP_Query($v_args);
I searched on the Internet, I could not resolve my problem ...
Thanks a lot.
-* : I also have a repeater field called Tags and in it a Taxonomy field in relation with tags. I would like to show all the books that have thig tag.