Get values from another post


All the template functions (get_field, the_field, etc) can be used to load values from another post, however, a second parameter is required to target the post.

Each post has a unique ID which can be found in the URL when editing, or found via code such as $post->ID.


Display a field

This example will display a field value from the post with an ID of 123.

<p><?php the_field('field_name', 123); ?></p>

Retrieving a field

This example will retrieve a field value from the post with an ID of 123.


$variable = get_field('field_name', 123);

// do something with $variable


Retrieving a field from post object

This example will retrieve a field value from a previously found $post object.


$variable = get_field('field_name', $post->ID);

// do something with $variable


Working with the Repeater Field

Note that when inside of a have_rows loop, you do not need to use the $post_id parameter for any sub field functions (get_sub_field, the_sub_field)

<?php if( have_rows('repeater', 123) ): ?>


    <?php while( have_rows('repeater', 123) ): the_row(); ?>

        <li><?php the_sub_field('title'); ?></li>

    <?php endwhile; ?>


<?php endif; ?>


⏰ It's finally time! ACF PRO pricing changes take effect on Monday, 24th February. Learn more

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.