Support

Account

Home Forums Add-ons Repeater Field Querying a relationship field in a repeater field Reply To: Querying a relationship field in a repeater field

  • Hi @jloupf

    I think I found the issue. It seems ‘post_where’ filter won’t work with get_posts() function. To fix it, you need to set suppress_filters option to false. Please take a look at the note on this page: https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where.

    So, your code should be something like this:

    $formations = get_posts(array(
        'suppress_filters' => FALSE,
        'post_type' => 'formation',
        'meta_query' => array(
            array(
                'key' => 'chapitres_%_lecon', // name of custom field
                'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
                'compare' => 'LIKE'
            )
        )
    ));
    
    if( $formations ): ?>
    . . .

    I hope this helps 🙂