0

I have created a relationship between my custom posts Work and Talent using Advanced Custom Fields.

I am currently showing posts from Talent on my work pages with the following posts:

<?php 

                    $artist = get_field('artist');

                    ?>
                    <?php if( $artist ): ?>
                        <ul>
                        <?php foreach( $artist as $artist ): ?>
                            <li>
                                <a href="<?php echo get_permalink( $artist->ID ); ?>">
                                    <?php echo get_the_title( $artist->ID ); ?>
                                </a>


                            </li>
                        <?php endforeach; ?>
                        </ul>
                    <?php endif; ?>

However I would like to be able to show/pull-through a field that is in my artist sections on my work pages. I have tried doing the below but it doesnt work:

<?php 

                    $artist = get_field('artist');

                    ?>
                    <?php if( $artist ): ?>
                        <ul>
                        <?php foreach( $artist as $artist ): ?>
                            <li>
                                <a href="<?php echo get_permalink( $artist->ID ); ?>">
                                    <?php echo get_the_title( $artist->ID ); ?>
                                </a>


                                <?php the_field( 'artist_summary' ); ?>
                            </li>
                        <?php endforeach; ?>
                        </ul>
                    <?php endif; ?>

1 Answer 1

1

Try adding artist ID as the second parameter in the_field(), like so:

<?php the_field('artist_summary', $artist->ID); ?>

http://www.advancedcustomfields.com/resources/functions/the_field/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.