Home Forums ACF PRO Sub field repeater query


Sub field repeater query

  • ACF PRO 5.6.6
    In a project I need to display a CPT (programmation) related to another one (lieux).
    In Programmation, I have a repeater filed named les_representations and a subfield ‘lieu_de_la_representation’ (post object)
    this is my code

    <?php $id_post_origine=get_the_ID();?>
        <a href="<?php echo the_permalink(); ;?>" title="<?php the_title_attribute(); ?>" target="_blank"><?php echo $id_post_origine?> <?php the_title(); ?></a></strong></td>
        <td><?php the_modified_date();?> à <?php the_modified_time();?></td>
    // args
    $args = array(
    'suppress_filters' => false,
    	'post_type' => 'programmation',
    	'meta_query' => array(
    			'key' => 'les_representations_%_lieu_de_la_representation',
    			'value' => $id_post_origine,
    			'compare' => 'LIKE'
    $the_query = new WP_Query( $args );
    <?php if( $the_query->have_posts() ): ?>
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    	<?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query();	 // Restore global post data stomped by the_post(). ?>     

    It doen’t display anything and i don’t understand why.
    Have you got any Idea ?

    Thanks a lot.

  • Hi @goushi

    Can you try following step 4 of this article:

    Update: Since the changed behaviour of esc_sql() in WordPress 4.8.3, it is not easy to use the % character as a placeholder for the following search and replace, instead, we recommend that you use the $ character as shown below.

    That may be causing your issue ^

    Please let me know if that helps, or if we need to dig a bit deeper.


Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Sub field repeater query’ is closed to new replies.