Home Forums Add-ons Repeater Field Get subfields from a repeater on one page to appear on another page


Get subfields from a repeater on one page to appear on another page

  • I’ve got a page template that uses an ACF repeater to display a grid of news articles. These are not blog posts, but a way to display external press that the client occasionally receives.

    The repeater field is called “news_article.” It contains the following sub-fields:

    • “article_title” (text field)
    • “source_link_text” (text field)
    • “source_link” (URL field)
    • “article_date” (date picker field)
    • “article_pull_quote” (text area field)
    • “article_description” (text area field)
    • “article_link” (URL field)
    • “homepage_featured_article” (true/false field)

    On the homepage of my site, I have a section where I’d like to display the “article_pull_quote” subfield based on whether or not the “homepage_featured_article” true/false field is clicked.

    I tried to implement this in my page template like this:

    <div class="feature-article">
    <h5>In the news</h5>
    <?php if( get_field('homepage_featured_article') ): ?>
    if( have_rows('news_article') ):
        while( have_rows('news_article') ) : the_row();
            $value = get_sub_field('article_pull_quote');
    <?php endif; ?>
    <a href="<?php echo get_site_url(); ?>/in-the-news/">See all news</a> 

    So far, it doesn’t work. I’m wondering if it has to do with the way I’ve nested my repeater?

    Any advice would be much appreciated!

  • When getting fields from another post you need to supply the post ID of the post you want to get them from. In the case of a repeater, this only needs to be done for the top level field

    if (have_rows('repeater_field', $post_id)) {
      while (have_rows('repeater_field', $post_id)) {

    More information here

  • This reply has been marked as private.
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.