Support

Account

Home Forums General Issues Get value from another post – can I get values from 2 other posts?

Solved

Get value from another post – can I get values from 2 other posts?

  • I would like to get values from a field in multiple posts. I have used the Repeater Field example from here (https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/) to pull in values from another post but what I really want to do is to pull values from 2 other posts. Is this possible? How do I do this?

    I tried putting an array in place of the post id but either I did it incorrectly or it isn’t allowed. Here is what I tried:

    <?php if( have_rows('testimonials', array(49, 51)) ): ?>
                 
                                            <?php while( have_rows('testimonials', array(49, 51)) ): the_row(); ?>

    Thanks!

  • You have to create 2 separate loops

    
    <?php 
      if( have_rows('testimonials', 49) ):
        while( have_rows('testimonials', 49)) ):
          the_row();
        endwhile;
      endif;
      if( have_rows('testimonials', 51) ):
        while( have_rows('testimonials', 51)) ):
          the_row();
        endwhile;
      endif;
      
    
  • I was afraid that was the answer. Thanks!

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

You must be logged in to reply to this topic.