Support

Account

Home Forums General Issues Best way to use ACF in Artist/Artworks relationship Reply To: Best way to use ACF in Artist/Artworks relationship

  • Here’s the code i’m using.

    
    <?php 
    
    						$series = get_field('serie_artist');
    
    						?>
    						<?php if( $series ): ?>
    							<?php foreach( $series as $serie ): ?>
    							
    								<h2><?php echo get_the_title( $serie->ID ); ?></h2>
    								
    								<?php
    									$oeuvres = get_posts(array(
    										'post_type' => 'artworks',
    										'post_status' => 'publish',
    										'meta_query' => array(
    											array(
    												'key' => 'art_serie',
    												'value' => $serie->ID,
    												'compare' => 'LIKE'
    											)
    										)
    									));
    								?>
    									<?php foreach( $oeuvres as $oeuvre ): ?>
    									
    									        <h3><?php echo get_the_title( $oeuvre->ID );  ?></h3>
    									<?php endforeach;?>
    							<?php endforeach; ?>
    							
    						
    													<?php else :
    														echo "No Works!"; ?>
    													<?php endif; ?>
    

    It’s basically this part i’m trying to get in the right order :

    	<?php foreach( $oeuvres as $oeuvre ): ?>
    									
    									        <h3><?php echo get_the_title( $oeuvre->ID );  ?></h3>
    									<?php endforeach;?>