Support

Account

Home Forums Front-end Issues Extract Post Object data from a Repeater field

Solved

Extract Post Object data from a Repeater field

  • Hello,

    I am trying to display data from a Post Object (link_internal_f), which is inside of a Repeater (footer_column_1).

    Screenshot

    I’ve populated the ACF with a page and I am trying to display the name of the page + permalink. But nothing in FE.

    This is my code:

    	
    <?php if( have_rows('footer_column_1') ): ?>
    
    <ul>
      <?php while( have_rows('footer_column_1') ): the_row(); ?>
       <?php
         $post_object = get_sub_field('internal_link_f');
           if( $post_object ): 
            // override $post
            $post = $post_object;
            setup_postdata( $post ); 
           ?>
          <li>									                                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
         </li>
    
         <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
        <?php endif; ?>
      <?php endwhile; ?>
    </ul>
    <?php endif; ?>

    Any help is welcome. Thank you.

  • I’ve figured it by myself. I was assigning this to Options, which means I had to add ‘option’.

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

The topic ‘Extract Post Object data from a Repeater field’ is closed to new replies.