I’m following this tutorial and I try to apply it to my website.
https://www.advancedcustomfields.com/resources/querying-relationship-fields/
I have artists thats plays in places.
An artist can play in different places, so i want to compare the row of the repeater field with the current place ID. And only show the row where the place is the same that the page.
But i don’t know how to achieve it…
Anyone can help me ?
Thanks
Here is the code for the place : single-place.php
<?php
function allow_wildcards( $where ) {global $wpdb;
$where = str_replace("meta_key = 'representation_%", "meta_key LIKE 'representation_%",
$wpdb->remove_placeholder_escape($where)
);return $where;}
add_filter('posts_where', 'allow_wildcards');
?>
<?php
$query = new WP_Query(array('post_type' => 'artiste',
'meta_query' => array(
array(
'meta_key' => 'representation_%_lieu_representation',
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE',
)
)
));
?>
<?php if($query->have_posts()) : while ($query->have_posts() ) : $query->the_post();?>
<?php if( have_rows('representation') ): while( have_rows('representation') ) : the_row();?>
<p>
<?php $date_rep = get_sub_field('date_representation');?>
<?php echo $date_rep; ?> <?php the_title();?>
</p>
<?php endwhile; else : endif; ?>
<?php endwhile; else: endif; wp_reset_postdata();?>