Trouble Getting Post Content in ACF Relationship Result

Share Now

you can’t pass the post ID to the get_the_content() or the_content() function. Please check this page to learn more about it:
If you want to get the content, you need to use the get_post() function instead. This page should give you more idea about it:
http://wordpress.stackexchange.com/questions/9667/get-wordpress-post-content-by-post-id

This will work

global $post;

$related_posts = get_field( 'related_posts' );

if( $related_posts ) : 
    foreach( $related_posts as $post ) : setup_postdata( $post );

        // This worked for me
        $output = apply_filters( 'the_content', $post->post_content );
        echo $post->post_content;
        
    endforeach;
    wp_reset_postdata();
endif;
Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert