If you configure the Post Object
field to return a post object instead of the post ids, it will deliver an array of post objects ready to use. No need to call global $post
, setup_postdata( $post )
, or wp_reset_postdata()
. All of that seems to just unnecessarily confuse the page that is loading the block. In order to retrieve the permalink, the title, the featured image etc. of the posts assigned to the block, just use $post->ID
within the foreach ( $posts as $post )
.