Support

Account

Home Forums General Issues Repeater field in template breaks in PHP 8 Reply To: Repeater field in template breaks in PHP 8

  • I have a similar problem it seems. I am using roughly:

    if( have_rows('related_items_list') ):
    			
     	// loop through the rows of data
        while ( have_rows('related_items_list') ) : the_row();
    		echo '<div class="related-item">';	
            // display a sub field value
            $postobject = get_sub_field('related_pages');
    
            echo '<div class="related-item-img" style="background-image: url('. $thumbnail  .')"><a href="'.get_permalink($postobject->ID).'" aria-hidden="true"></a></div>';
    		echo '<div class="related-details"><h3><a href="'.get_permalink($postobject->ID).'">'.$postobject->post_title.'</a></h3>';
    		echo '<div class="related">'.$postobject->post_excerpt.'</div>';
    		echo '</div></div>';	
    		
        endwhile;
    	wp_reset_postdata();
    endif;
    

    and the final error it throws is roughly:

    PHP Fatal error: Uncaught TypeError: strpos(): Argument #1 ($haystack) must be of type string, WP_Post given in .... /wp-includes/shortcodes.php:209

    it does this every time i try to use get_sub_field in a repeater.

    This all worked fine in PHP 7 and is failing in PHP 8