Home Forums Front-end Issues Issue with retrieving page object from repeater sub field


Issue with retrieving page object from repeater sub field

  • Hello,
    I’m using ACF PRO v5.6.10 on WordPress 4.9.7.

    I’m having issues with the snippet from front-page.php pasted below. Sometimes and very rarely a page object is not returned and all of the output refers to “Home” (since get_the_title() uses the current page if no argument is provided). I can verify that a page object has been selected in the backend. Is there any reason why $feature = get_sub_field(‘page’); would return an empty object intermittently? This displays incorrect information on our production home page. I cannot recreate this locally unless I unselect a page object in the backend.

    Any help would be appreciated!

    <?php if (have_rows('primary_links')): ?>
        <ul class="primary-links">
        <?php while (have_rows('primary_links')): the_row();
            $feature = get_sub_field('page');
            $featured_link = (get_sub_field('override_url') ? get_sub_field('override_url') : get_permalink($feature));
            $featured_title = (get_sub_field('override_title') ? get_sub_field('override_title') : get_the_title($feature));
            $featured_image = get_sub_field('override_image');?>
            <li><a href="<?php echo $featured_link; ?>">
                <img alt="<?php echo $featured_image['alt']; ?>" src="<?php echo $featured_image['sizes']['featured']; ?>"/>
                <span><?php echo $featured_title; ?></span></a>
    		<?php endwhile;?>
    <?php endif;?>


  • Just realized that none of the get_sub_field functions are working. Even though values exist in the backed. Any ideas?

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

The topic ‘Issue with retrieving page object from repeater sub field’ is closed to new replies.