Support

Account

Home Forums Front-end Issues Post Object: Selection does not show up in Custom Post Type Reply To: Post Object: Selection does not show up in Custom Post Type

  • @Jonathan: YOU. ARE. AWESOME.

    Here’s the code I used outside the loop to generate the field output for anyone else who’s searching to solve the same problem.

    
    <?php 
    $post_id = get_the_ID(); // if ACF is outside loop, use this to get post ID
    $post_objects = get_field('banner_selection', $post_id); // use second parameter to get the fields from this post
    echo $post_id // Optional: use this to check if the ID is correct for this post
    ?>
    <?php if( $post_objects ):  // if banner selection was made, show those ?>
    
    <?php foreach( $post_objects as $post): ?>
    	<?php setup_postdata($post); ?>
    	<?php get_template_part( 'banner','side' ); ?>
    <?php endforeach; ?>
    <?php wp_reset_postdata(); ?>
    
    <?php endif; // end if banner selection was made ?>
    
    

    To output selection fields for Post Object fieldtype in ACF.