Support

Account

Home Forums Add-ons Repeater Field reverse querying and repeater field

Solved

reverse querying and repeater field

  • I am having a problem getting the second row of a repeater field in a reverse query.

    I have this code that gets the id qualiteutilise_0_qualite (repeater field and subfield) from modele (custom post type) .
    This works fine. Except I have multiple repeater fields (qualiteutilise). How can I get qualiteutilise_1_qualite, qualiteutilise_2_qualite etc…

    I need to somehow be able to loop through them but i am not sure how to achieve this. I hope someone can shed some light… thanks for this plugin.

    $modeles = get_posts(
    array(
    	'post_type' => 'modele',
    	'meta_query' => array(
    		array(
    		'key' => 'qualiteutilise_0_qualite', // name of custom field
    		'value' => '"' . get_the_ID() . '"', 
    		'compare' => 'LIKE'
    			)
    	)
    ));
    
    ?>
    <?php if( $modeles ): ?>
    <ul>
    
    <?php foreach( $modeles as $modele ): ?>
    <?php 
    <li>
    <?php echo get_the_post_thumbnail( $modele->ID, 'sarlap-150' ); ?>
    </li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
  • I can just repeat this code and replace

    qualiteutilise_0_qualite with qualiteutilise_1_qualite 
    

    to get the second line but feel this is not the way forward.

  • This reply has been marked as private.
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘reverse querying and repeater field’ is closed to new replies.