Home Forums Front-end Issues Repeater – Page Link (Show ACF from that page)


Repeater – Page Link (Show ACF from that page)

  • I have a custom field for the page image background_image and I have also created a repeater on another page with page link to pull those pages through.

    I have been able to get the page URL and the page title but can’t get that custom field to appear. I’ve tried a variety and feel this is close but no success;

    <?php if( have_rows('other_pages') ): ?>          
        <div class="flex-wrapper">
            <?php while( have_rows('other_pages') ): the_row(); ?>    
                    // vars
                    $post_id = get_sub_field('other_page_selector', false, false);
                    // check 
                    if( $post_id ): 
                    <div class="flex-shell" style="background-image:url('<?php get_the_field('background_image, $post_id'); ?>');">
                        <div class="overlay"></div>
                        <div class="flex-item">
                            <div class="subpage">
                                <a href="<?php echo get_the_permalink($post_id); ?>"><?php echo get_the_title($post_id); ?></a>
                <?php endif; ?>      
            <?php endwhile; ?>
    <?php endif; ?> 
    <?php wp_reset_query(); ?>
  • Is this a typo in your code or just what you posted here

    get_the_field('background_image, $post_id');

    should be

    get_the_field('background_image', $post_id);
  • I tried it and got an error;

    <b>Fatal error</b>: Uncaught Error: Call to undefined function get_the_field()

  • Got it with;

    echo the_field('background_image', $post_id);


  • Sorry, I copied the function you had in your code and didn’t even notice that it was wrong while I did notice the misplaced single quote.

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

You must be logged in to reply to this topic.