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;?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.