
Hi,
I just discovered Post Object fields type and I was hoping for some advice on what is good practise?
My plan is to have 3 different Post Object -fields where each one would setup a select list (from 3 separate CPT:s).
This should produce 3 different ”related content -areas” below the main article/loop.
In short, I was hoping something like this could work (from hook outside main loop, placed in functions.php):
$post_object = get_field(’cpt-one’);
if( $post_object ) {
$post = $post_object;
setup_postdata( $post );
$cpt-content = $post_object->post_content;
$cpt-id = $post_object->ID;
echo get_the_post_thumbnail( $idtest, 'thumbnail' );
echo $cpt-content;
wp_reset_postdata();
}
$post_object = get_field(’cpt-two’);
if( $post_object ) {
$post = $post_object;
setup_postdata( $post );
$cpt-content = $post_object->post_content;
$cpt-id = $post_object->ID;
echo get_the_post_thumbnail( $idtest, 'thumbnail' );
echo $cpt-content;
wp_reset_postdata();
}
$post_object = get_field(’cpt-three’);
if( $post_object ) {
$post = $post_object;
setup_postdata( $post );
$cpt-content = $post_object->post_content;
$cpt-id = $post_object->ID;
echo get_the_post_thumbnail( $idtest, 'thumbnail' );
echo $cpt-content;
wp_reset_postdata();
}
Is it a bad idea, performance wise?
Grateful for any advice/comments, thanks!