Support

Account

Home Forums ACF PRO Relationship Page in Post

Helping

Relationship Page in Post

  • Hi all.
    At the outset, I would like to apologize because I hardly speak English. But I’ll try to ask a question.

    I would like to get the desired effect.

    I have posts (Post), to which I add a new field (relationship) choosing from a page (Page), respectively for the selected page some examples of fields (text, textarea, url).

    How to display posts in a given field of the chosen page, we have chosen using Relationship

    Zoom

    I hope clearly written. Thanks to all for your help.

  • Have you tried using the help documents? Here’s a great post with PHP examples: http://www.advancedcustomfields.com/resources/relationship/

    <?php 
    
    $posts = get_field('relationship_field_name');
    
    if( $posts ): ?>
        <ul>
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
            <?php setup_postdata($post); ?>
            <li>
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                <span>Custom field from $post: <?php the_field('author'); ?></span>
            </li>
        <?php endforeach; ?>
        </ul>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    Or are you trying to do this without any custom coding?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Relationship Page in Post’ is closed to new replies.