Support

Account

Home Forums Add-ons Repeater Field Get post ID from Post Object in Repeater Field Reply To: Get post ID from Post Object in Repeater Field

  • Hi Eliot,

    I figured it out — with your guidance of course!

    I updated the code based on your sample that takes just one selection to the following:

    <?php while(the_repeater_field('home_clients_logos')): ?>
        <?php $clientLink = get_sub_field('client_link'); ?>
         <li><a href="<?php echo get_permalink(28); ?>
            <?php if( $clientLink ) : ?>
                <?php $post = $clientLink; ?>
                <?php setup_postdata( $post ); ?>#<?php echo get_the_ID(); ?>
                <?php wp_reset_postdata(); ?>
            <?php endif; ?>"></a></li> 		
    <?php endwhile; ?>

    I replaced:
    <?php the_sub_field( 'client_link', $post->ID ); ?>

    with:
    <?php echo get_the_ID(); ?>

    Thanks again for your help and super-quick response!